Interesting Django project folder structure.

310 views
Skip to first unread message

Tianyi Wang

unread,
Apr 21, 2014, 10:00:26 AM4/21/14
to django...@googlegroups.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

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.

Do you guys think it's a good idea? 

Cheers

Tianyi  

Mrinmoy Das

unread,
Apr 21, 2014, 10:04:42 AM4/21/14
to django...@googlegroups.com

Hi,

The suggested folder structure is the standard stuff that is generally used. I personally and all the teams I have worked with uses this particular structure.

sent form mobile, apologies for the brevity

--
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...@googlegroups.com.
To post to this group, send email to django...@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.

Tianyi Wang

unread,
Apr 21, 2014, 12:33:48 PM4/21/14
to django...@googlegroups.com
Hi,

Cool. But I see it'd work pretty nicely when you have many custom apps and libs.

When you do "./manage.py startapp newapp", Django create the "newapp" as the layout I'm using.
AndI have a Django site which contains four Custom apps. The layout I'm using works fine. Just wonder is there
any other benefits to change to the suggested layout?

Cheers 

Amirouche Boubekki

unread,
Apr 23, 2014, 10:09:58 AM4/23/14
to django...@googlegroups.com
2014-04-21 16:00 GMT+02:00 Tianyi Wang <wty5...@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 :)

Perry Arellano-Jones

unread,
Apr 24, 2014, 12:41:54 PM4/24/14
to django...@googlegroups.com
It's mostly preference, use what suits you.  I prefer having all of my apps in an 'apps' directory for organization's sake.  I may not have an issue keeping track of them now, but if a project gets large it could get unruly.  Anyone else that wants to contribute to any of my projects may benefit from the clarity as well. To create a new app in a subdirectory, all you need to do is specify the path with startapp. Simple example from your project root:

mkdir -p ./apps/new_app
./manage.py startapp new_app ./apps/new_app

Damián Pérez

unread,
Apr 25, 2014, 10:26:52 AM4/25/14
to django...@googlegroups.com
Hello,

I read that the folder apps itsn't recomended.

You can see this structure: https://github.com/damianpv/skeleton_django

Best regards,
Reply all
Reply to author
Forward
0 new messages