django-admin.py startproject returns CommandError - django

I've just installed django and I'm having trouble creating a project.
Running django-admin.py startproject test_project returns:
CommandError: '/usr/local/mysql-5.6.13-osx10.7-x86_64/docs/test_project' already exists
I also looked in the path above and there is no test_project folder.
Anybody come across this one?
EDIT
I restarted the terminal and tried again. The error has disappears but it doesn't seem to be creating the test_project folder on my desktop.

You seem to have found your solution through gersande's comment (update your question if you haven't with the new problem); so I'm just going to formalize it here:
I restarted the terminal and tried again. The error has disappears but it doesn't seem to be creating the test_project folder on my desktop.
I'm not sure why restarting the terminal helped (and it's probably a heisenbug), but I do notice an incongruence in your question: you've (seemingly, as the command isn't outputting any errors; but you could confirm by checking if running echo $? is 0 right after) created you new Django project directory in /usr/local/mysql-5.6.13-osx10.7-x86_64/docs/, but you seem to be looking for it on your Desktop (which is mapped to a different folder, probably ~/Desktop.
Simply navigate to the above path in your file explorer, or run cd <directory> to view it in your terminal.

Related

django-admin command error while project creation

After upgrading to django 1.9 and tried creating new project.Getting following error
How should i solve this?
After upgrading to django 1.9 and creating new project following error occurred
CommandError: /home/shaastr/ehgg/manage.py already exists, overlaying a project or app into an existing directory won't replace conflicting files
I think you have 2 versions of django installed, and both are being called when trying to start the project.
Try running pip uninstall django twice, if it runs both time then this was what was going on. Obviously, pip install django afterwards to get it working again
I had the same problem after using pip to install django 1.10 over an older version.
I used pip to uninstall and manually deleted the leftover django folder in the site-packages folder.
re-installed using pip, and now it is working with no problem.
I am also working with docker containers. I had this problem where it said that manage.py already exists in the workdirectory (that I made through the Dockerfile file) when I tried to restart the process of making a container after deleting the old one.
It did not show me where the workdirectory was made and hence could not delete the manage.py as pointed out in the error.
The solution that worked was I changed the service name in my yml file and gave the command with new servicenm
docker-compose run servicenm django-admin.py startproject projectnm directory
remove manage.py then re-run your django-admin startproject command, it will work
Make sure that if you have deleted (rm -r) "your Django project_name" to also delete (rm) the manage.py corresponding deleted project python file in the same repository.
sudo pip uninstall django
sudo rm /usr/local/lib/python2.7/dist-packages/django/ -rf
sudo pip install django==1.10
This resolved my problem.
You need to define another directory for your new project. Not /ehgg directory.
It seems though you are creating a new project inside your old project.
And this error clearly state that, there is old setting i.e "manage.py" for your old project. Since every time a new settings manage.py created for your new project.
I hope it's clear to you.
Thank you.
Check whether the project name is correct or not. Django avoids
hypens (-) in project names.
It can happen due to two reasons:
You are trying to create a new folder with the exiting folder name.
You have previously deleted a folder with this name. Deleted it for some reason. But again trying to create package with this name.
To resolve this follow
Rename the manage.py from your project folder.
Go to <%System Path%>/PycharmProjects/<%Your Project Name%>/.idea/workspace.xml
edit this file "workspace.xml" and then search with the package name you are trying to create.
delete that line and save the file.
Now try to run the command again.
I hope this helps.
Regards,

Admin shows entries of a model even though database is empty

How is the following possible?
I cloned a django project into a dir, ran syncdb, check_permissions, migrate, createsuperuser and ran my development server. I then went to the admin and there I saw 2 entries of a model even though there are no fixtures that could cause these entries. When I looked at my sqlite database file, there are no entries for that model, even though it shows these two entries in the admin(I also did python manage.py dumpdata > my_db and case insensitively searched within that file, no result). It's also not browser related because the problem also occurs on a new installed browser.
These 2 entries are entries I made in the development server of the project on another location. But that server is not running and I'm using a different port.
I also grepped (grep -r -n entry_name) from my root folder looking for the names of those entries, however without result.
When I select these entries in the admin and click delete, nothing happens. These two entries remain there.
Edit 1
#Hedde:
I did ps ffaux|grep python . There is only one Django process running: /home/my_username/.virtualenvs/project_name/bin/python manage.py runserver 8044
I gave each of my settings files a print line to identify when each is running. Only the development settings is run, like expected and has always been the case.
I am using sqlite3 for the database, there is only one my_database.db file in my project dir. (find . -iname *db* only returns one database file)
Edit 2
When I clone the project from another pc and do the whole procedure listed above(syncdb, check_permissions, migrate, createsuperuser and run development server) everything works as expected, the entries are gone.
The problem was related to Redis. Simply flushing the Redis-db solved the problem.
$ redis-cli
$redis> flushall
$redis> exit

Creating a project with Bitnami DjangoStack?

I just installed the Bitnami DjangoStack and want to know how to create a new project in Windows.
I tried opening the python.exe (similar to command prompt) and tried typing in:
django-admin.py startproject testproject which is what many articles seem to say to start with.
I am getting an invalid syntax error. Do I need to do something else? Eager to get started!
django-admin.py is a shell command, not a python statement. Issue it in a cmd window.
Make sure the path to django-admin.py is in your environment variables or in PYTHONPATH. Since this is a special DjangoStack distribution I guess it's in there.

Django App not working: "Error: No module named app_name"

I'm new to Django, and I can't figure out why my app isn't loading. I've created all the files: models.py, views.py, urs.py with default code in. But when I run python manage.py runserver, it says the following:
Error: No module named app_name
What am I doing wrong?
Did you remember to include __init__.py in your folder?
If you did, make sure the permissions on the file are also correct. There's also a similar question here.
Just an additional hint: Instead of manually creating the files you can use django-admin.py startapp APPNAME to automatically create a directory with all necessary files for a new app.
I got your point the init file thing also dosen't work out for me as well. Just ensure that are you writing the proper command inside the proper directory while creating the app, using the terminal.
Like while writing the command "django-admin startapp APP_NAME", ensure that the command is written inside your root configuration directory (which gets created after you typein command "django-admin startproject PROJECT-NAME"), not anywhere else. Then mention the app name inside the settings.py file, under the INSTALLED_APPS[ ] list. Then finally run the command "python manage.py runserver" in the same root configuration directory. I assure you, this will work for sure and the "No modules found" thing will disappear. Have a try and tell me if it don't. Thank you.

Django + Virtualenv: manage.py commands fail with ImportError of project name

This is blowing my mind because it's probably an easy solution, but I can't figure out what could be causing this.
So I have a new dev box and am setting everything up. I installed virtualenv, created a new environment for my project under ~/.virtualenvs/projectname
Then, I cloned my project from github into my projects directory. Nothing fancy here. There are no .pyc files sitting around so it's a clean slate of code.
Then, I activated my virtualenv and installed Django via pip. All looks good so far.
Then, I run python manage.py syncdb within my project dir. This is where I get confused:
ImportError: No module named projectname
So I figured I may have had some references of projectname within my code. So I grep (ack, actually) through my code base and I find nothing of the sorts.
So now I'm at a loss, given this environment why am I getting an ImportError on a module named projectname that isn't referenced anywhere in my code?
I look forward to a solution .. thanks guys!
Is projectname exactly (modulo suffix) the name of the directory the project is in? Wild guess, but I know Django does some things with the current directory…
Also, what is trying to import projectname? Do you get a traceback? If not, try running with py manage.py --traceback syncdb and see what happens.