Wednesday, April 23, 2014

Re: Interesting Django project folder structure.




2014-04-21 16:00 GMT+02:00 Tianyi Wang <wty52133@gmail.com>:
Today I was reading through http://www.deploydjango.com/django_project_structure (great resource)

The suggested folder structure for a Django project from this site is like below:
(I'm only interested in layout for Django apps, not requirements files or settings files)

  myproject      |-- manage.py
    |-- requriements.txt      |-- myproject          |-- __init__.py
        |-- settings.py          |-- urls.py          |-- wsgi.py
        |          `-- apps
            |-- __init__.py
            |-- app_one
            |   |-- __init__.py              |   |-- models.py              |   |-- views.py              |   `-- urls.py              `-- app_two                  |-- __init__.py                  |-- models.py                  |-- views.py                  `-- urls.py

I don't see the point of this structure really. Maybe, it's kind of helpful to figure quickly where are the "app" directories, which can not be immediate matter if you have other directories in myproject/ like template_tags/ or urls/, why would you do that anyway?

I prefer your setup:
 
My current setup is like below:

myproject      |-- manage.py
    |-- requirements.txt      |-- myproject      |   |-- __init__.py      |   |-- settings.py      |   |-- urls.py      |   `-- wsgi.py      `-- app_one      |   |-- __init__.py      |   |-- models.py      |   |-- views.py      |   `-- urls.py      `-- app_two          |-- __init__.py          |-- models.py          |-- views.py          `-- urls.py

The reason for the first layout is to categorise the apps, 
so one can have a "apps" folder contains all the custom apps;
    "libs" folder contains all the lib/helper apps and such.

Or something more sophisticated like:

myproject/
 myproject/ # created by startproject command, holds settings and stuff
 generic/  # holds generic apps
 integration/  # holds integration only apps of generic apps (apps that only link to generic apps)
 custom/  # holds specific apps they can make use of any other kind of apps
 helpers/  # non app libraries
 
requirements.txt is usually not in a python package but in the root source directory.

Do you guys think it's a good idea?
Yes, as soon as you don't loose too much time fiddling with such matter, it's helpful :)
 

Cheers
    
Tianyi  

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/37ecd6cb-6dcc-431e-ae39-3814dbf647de%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAL7_Mo9f6%3D6Z1%2BPYoO3_4D_unQtvHz_oadpggZm_1dW1%2BE%3DbDQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment