Once a Django project has been created using cookiecutter-django, is there a command like python manage.py startapp <app_name>
to run instead of writing the new app from scratch?
Cookiecutter Django renders a Django project, and included with the files is a manage.py
module. If you have Django installed, you can just call python manage.py startapp <app_name>
and it should just work.
startapp
creates the app in the first level, the same directory where manage.py
is. Why not create the app in the <project_name>/
level, where also the users
app is?" Where am I wrong? –
Feckless For the sake of completeness, I would like to add that project-specific apps should go into the second level, also when using Cookiecutter Django.
There is a GitHub issue about this, where a project maintainer explains the situation.
What you should do is the following:
1 - create the
<name-of-the-app>
app withpython manage.py startapp
2 - move<name-of-the-app>
directory to<project_slug>
directory
3 - edit<project_slug>/<name-of-the-app>/apps.py
and changename = "<name-of-the-app>"
toname = "<project_slug>.<name-of-the-app>"
4 - add"<project_slug>.<name-of-the-app>.apps.<NameOfTheAppConfigClass>"
toLOCAL_APPS
inconfig/settings/base.py
cookiecutter-django
, it wasn't even entirely clear if I had to create an app right way, or if it had been somehow handled by the generation process. –
Borchardt Cookiecutter Django renders a Django project, and included with the files is a manage.py
module. If you have Django installed, you can just call python manage.py startapp <app_name>
and it should just work.
startapp
creates the app in the first level, the same directory where manage.py
is. Why not create the app in the <project_name>/
level, where also the users
app is?" Where am I wrong? –
Feckless This is a good question as it is recommended to create a new app for every feature.Solution to this would be to call manage.py from the project directory. The call will look like this:
python ../manage.py startapp <name_of_app>
You would still need to rename your app.py
and you need to add the app settings/base.py
under local apps.
© 2022 - 2024 — McMap. All rights reserved.