Almad escribió:
> Hi,
> I'd like to ask how to organize Django application. To me, structure
> of project/app is nice idea, however I have problems applying it in
> practice, so I'd like to ask about best practices.
> Problems come, when application structure become deeper and nested. Is
> it usual to start an application inside application? Django-admin
> disagree with it.
> How is it with dependencies? When part of application depends on
> another, should it be subapplication, or normal top-level application
> depending on another one?
> Plus, when django philosophy is to have "application packages", why
> are templates separated into another directory structure? I'm more
> familiar (from my personal cherrypy structure) with lib/apps for
> model, tpl/apps and web/apps separation for M/V/C, but django seem to
> mixing it together.
> What are reasons for this and what are best practices for structuring
> bigger/complicated apps?
Here's an example of my latest project structure:
/var/www/django <---- this is on the pythonpath. everything else,
beneath it.
tagging, registration, etc. <----- apps I consitently use across most
projects are held just there. These are all svn checkouts. In case there
is a backwards incompatible change affecting a project, the app gets
copied into the project folder.
project/ <--- the root project folder (eg. contains the settings and url
files) is beneath the django folder, among the common apps.
project/webroot/static <---- contains the files to be served statically
project/webroot/php <---- I'm a minter :P and I keep php stuff on a
separate subdomainm just in case I need to move it.
Then, if an app is particularly bound to some project (eg a project with
a single app, or apps being used ONLY for that project) are held beneath
the project root. Each app holds it's own template directory. The app
template loader looks for this directory when loading a template.
Actually, my default project setup is pretty different from what you get
with startproject <name>. I wonder how I could change the template it
uses...