Organising django projects

238 views
Skip to first unread message

Almad

unread,
Jul 28, 2007, 5:09:27 AM7/28/07
to Django users
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?

Chris Hoeppner

unread,
Jul 28, 2007, 6:58:44 AM7/28/07
to django...@googlegroups.com
Almad escribió:
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...

Justin Lilly

unread,
Jul 28, 2007, 11:32:24 AM7/28/07
to django...@googlegroups.com
It occurs to me that django-admin looks for a template page in the project and it it isn't there, it defaults to another admin template. It would seem as though it might be good for modularity if we had something similar to:

attempts to render app1
/home/dev/django/proj1/template_dir/app1
/home/dev/django/proj1/app1/template_dir
then normal path

This would help out a lot if we could set this up. (I know it would be something HCoF would be interested in). Basically if a project specific template isn't there, it will default to the application specific template. It might also be nice to change this priority listing via settings.py.

 Has this been discussed before? What are the dev's feelings on this?

-justin

--
Justin Lilly

Almad

unread,
Jul 29, 2007, 5:24:14 AM7/29/07
to Django users

> Has this been discussed before? What are the dev's feelings on this?

I'd like to hear them too.

> -justin

Almad

Reply all
Reply to author
Forward
0 new messages