Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a command for creating an app using cookiecutter-django?

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?

like image 413
dolma33 Avatar asked Oct 03 '16 18:10

dolma33


2 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 with python 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 change name = "<name-of-the-app>" to name = "<project_slug>.<name-of-the-app>"
4 - add "<project_slug>.<name-of-the-app>.apps.<NameOfTheAppConfigClass>" to LOCAL_APPS in config/settings/base.py

like image 137
Thomas Kainrad Avatar answered Nov 15 '22 22:11

Thomas Kainrad


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.

like image 24
pydanny Avatar answered Nov 15 '22 23:11

pydanny