2

I have a pretty simple question here:

I'm starting out with Django but i'm needing to know which one of the following is more proper (the django way):

  1. Having the app under the django_project like this: /root/project/app
  2. Or Having the Django_project and the django_app under the same /root/ directory in parallel?
3
  • A project may consist of many apps. I suggest you to read a Django tutorial first and follow the best practice recommended in that tutorial. Commented Nov 21, 2018 at 23:24
  • 1
    Having the app under the django_project like this: /root/project/app Commented Nov 22, 2018 at 3:56
  • Does this answer your question? Best practice for Django project working directory structure Commented Feb 24, 2021 at 8:46

1 Answer 1

1

There are several thoughts of how to do this best, and only you and your team can find out what works best for you. The Django tutorial recommends keeping apps in parallel to the configuration directory. My team has settled on a few things over time:

From the project root:

.gitignore manage.py README.md +---config +---urls.py +---wsgi.py +---settings.py +---requirements +---templates +---static +---app1 +---models.py, etc +---app2 

Some prefer another directory layer above the project level, but that has felt like overkill to our projects. We have settled as a team on naming each project's configuration subdirectory config, rather than the project name repeated. This is just personal preference, but has worked for us. Good luck!

Sign up to request clarification or add additional context in comments.

4 Comments

Did you make your project name “config”?
I didn't; if I run django-admin startproject myproject, the first thing I do it rename the subdirectory myproject to be config, and edit config/settings.py to replace instances of myproject with config, such as myproject.urls becoming config.urls. That way, all of our projects have their configurations in the same subdirectory.
Wouldn’t doing ‘Django-admin startproject config .’ have the same effect?
Six of one, half-dozen of another: there are some comments in the boilerplate that also insert the project name. But yes, probably easier that way, as they are just comments. Good idea!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.