1

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?
vvvvv
  • 25,404
  • 19
  • 49
  • 81
aphexlog
  • 1,503
  • 3
  • 16
  • 43
  • 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. – Selcuk Nov 21 '18 at 23:24
  • Having the app under the django_project like this: /root/project/app – prisar Nov 22 '18 at 03:56
  • Does this answer your question? [Best practice for Django project working directory structure](https://stackoverflow.com/questions/22841764/best-practice-for-django-project-working-directory-structure) – mx0 Feb 24 '21 at 08:46

1 Answers1

0

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!

FlipperPA
  • 13,607
  • 4
  • 39
  • 71
  • 1
    Did you make your project name “config”? – aphexlog Nov 22 '18 at 04:14
  • 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. – FlipperPA Nov 22 '18 at 13:26
  • 2
    Wouldn’t doing ‘Django-admin startproject config .’ have the same effect? – aphexlog Nov 22 '18 at 15:31
  • 1
    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! – FlipperPA Nov 23 '18 at 02:43