Cannot start any django app
I had the same issue because I was trying to "restart" my app after carrying out changes, but startapp
is meant to be used once to create a new app. To view changes, syncronize app with DB with python manage.py migrate
and restart the server with python manage.py runserver
instead.
From the django-admin
docs
(manage.py
does essentially the same thing as django-admin
)
startapp <app_label> [destination]
django-admin startapp
Creates a Django app directory structure for the given app name in the current directory or the given destination.
By default the directory created contains a models.py file and other app template files. (See the source for more details.) If only the app name is given, the app directory will be created in the current working directory.
If the optional destination is provided, Django will use that existing directory rather than creating a new one. You can use ‘.’ to denote the current working directory.
For example:
django-admin startapp myapp /Users/jezdez/Code/myapp
Perhaps you need to
cd panel
python manage.py startapp yourappname
I'm not sure running the command from a directory above your project will work properly.
This is a fun one - your project and your app need to have different names. You probably created a project, then tried to startapp with the same name.
I was confused as well, until I realized that a Django project is a container for applications; this sequence makes it a bit clearer:
# first create a Project (container).
django-admin.py startproject Project
# create multiple apps
cd Project
python manage.py startapp polls
python manage.py startapp hello
...