My advice is If you find yourself breaking models, views, utils, etc. into 
separate files within an app, you should really consider breaking your app into 
multiple apps.  I hit this myself in or own project and found myself dealing 
with the auto registration functionality for admin.py, tasks.py, and a bunch of 
other too-large files.  I bit the bullet and broke things out and my 
import/discovery headaches disappeared.  My individual py files got small and 

+--major_app
     +--docs
     +--templates
          +-- (img, js, css, base.html)
     +--projects
          +--dev
          +--test
          +--deploy
     +--apps
          +--sub_app1    (create with startapp command)
               +--models.py
               +--tasks.py
               +--templates
               +--tests.py
               +--urls.py
               +--views.py
               +--...
          +--sub_app2
               +-- .....

I put this in the top of my settings.py files down in projects/dev or 
projects/test, or projects/deploy so that the apps just get discovered.

# the base directory is up two levels from the project
PROJDIR = os.path.abspath(os.path.dirname(__file__)) + '/'
PROJNAME = PROJDIR.split('/')[-2]
BASEDIR = os.path.abspath(os.path.join(PROJDIR, '..', '..')) + '/'
APPSDIR = os.path.abspath(os.path.join(BASEDIR, 'apps')) + '/'

# add apps and projects directory to path
sys.path.insert(0, PROJDIR)
sys.path.insert(0, APPSDIR)

Brian

Brian Schott
bfsch...@gmail.com

On Jan 7, 2012, at 2:24 PM, IgorS wrote:

> Below is my current structure. I am new to Django and probably missing
> something... Restructuring an application somewhere in the middle of
> the development cycle is more expensive than just having the "right"
> layout from the start. Especially if this is possible. I consider a
> small overhead at the start being better than a great rework in the
> middle (yes, i am aware of the minimal viable product concept :-)
> 
> app
>       +--models
>               ---abstract_base.py
>               ---core.py
>               ---...
>       +--probe
>       +--static
>               ---css
>               ---js
>               ---images
>       +--templates
>               ---base.html
>               ---...
>       +--tests
>               ---test_users.py
>               ---...
>       +--utils
>       +--views
>       ---__init__.py
>       ---app_settings.py
>       ---context_processors.py
>       ---middleware.py
>       ---urls.py
> 
> Thank you,
> -igor

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to