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?

- 4,133
- 6
- 28
- 48
3 Answers
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

- 2,542
- 21
- 26
-
1Thanks that is very useful. For me, after having run `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. – cjauvin Aug 28 '20 at 17:42
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.

- 7,954
- 6
- 34
- 42
-
1For some reason I was thinking that running the usual Django startapp wasn't enough and produced an architecture that doesn't fit with cookiecutter-django's architecture, and because of that there *had to be* an analog command somewhere... Looks that I was wrong ;) – dolma33 Oct 24 '16 at 15:39
-
2I guess that I was thinking something like this: "`startapp` creates the app in the *first level*, the same directory where `manage.py` is. Why not create the app in the `
/` level, where also the `users` app is?" Where am I wrong? – dolma33 Oct 24 '16 at 15:54 -
3Before noticing the answer's author, I started digging around in the Two Scoops to verify this. It actually looks like it's meant to be on the top level. Cookiecutter Django adds a lot of functionality, but still on the same level as startproject. So, while you can add apps like you describe, the first level still remains the typical place. – Masa May 31 '17 at 21:57
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.

- 21
- 3