When creating a new app using python manage.py startapp <name-of-the-app>, the application is created within the project root
The application should be created within the project slug, as indicated here
pip install -r requirements/local.txtpython manage.py startapp foo@JCepedaVillamayor
What happened?
When creating a new app using python manage.py startapp, the application is created within the project root
this is the expected behavior, because cookiecutter-django does not change the way that django startapp works. ( I tried doing this in another branch, but, I did not like having to rewrite almost everything to include this relatively simple logic. the django startapp, apparently, was not projected to be extended :cry: )
you'll have to fix this manually:
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>", on your LOCAL_APPS on config/settings/base.py
if that is enough to answer the question. please close this issue.
We gladly accept code and documentation contributions.
Oh, I see, I misunderstood the meaning of the comment. Thank you for the manual fix, this was the steps I were doing before.
I'll be glad to document the project if needed (maybe on Troubleshooting?)
I close the issue for now, let's see how we proceed then.
Why am I getting a ModuleNotFoundError: No module named '<project_slug>.<name-of-the-app>.urls' when I add the new app onto the config/urls.py? I followed the above example but got the error when running the local server
As a newcomer to both Django and cookiecutter-django, I was confused by two aspects related to this issue:
cookiecutter-django, whether I needed to also explicitly create an app afterward or not (it seems that it is the case, because only the "Users" app is created right after the project has been generated)This would seem to be a subject/issue worthy of documentation, perhaps inclusion in the startapp work flow. I see manual fixes presented as a reply to an issue, but surely this is worth addressing to the wider audience who may not come into the issues for a solution? Is this just me?
Most helpful comment
@JCepedaVillamayor
this is the expected behavior, because cookiecutter-django does not change the way that django
startappworks. ( I tried doing this in another branch, but, I did not like having to rewrite almost everything to include this relatively simple logic. the django startapp, apparently, was not projected to be extended :cry: )you'll have to fix this manually:
1 - create the
<name-of-the-app>app with python manage.py startapp2 - move
<name-of-the-app>directory to<project_slug>directory3 - edit
<project_slug>/<name-of-the-app>/apps.pyandchange
name = "<name-of-the-app>"toname = "<project_slug>.<name-of-the-app>"4 - add
"<project_slug>.<name-of-the-app>.apps.<NameOfTheAppConfigClass>",on yourLOCAL_APPSonconfig/settings/base.pyif that is enough to answer the question. please close this issue.
We gladly accept code and documentation contributions.