Johan writes:
I think so, too.
I did some research on this two weeks ago and my impression was that
there are no guidelines at all to create portable apps. On the
contrary, the template path in the official Django tutorial is
example.
My own guidelines are inspired from the Pinax project which seems to
be quite far in this direction.
Templates: Have them in myproject/myapp/templates/myapp/, including
the base.html. base.html extends site_base.html which resides in
myproject/myapp/templates/ but is usually overridden in
myproject/templates/. site_base.html should contain the blocks
title, css, extrahead, and content. Additionally, there should be
"title" in the context.
Static files: Have them in myproject/myapp/media/myapp/ and use
django-staticfiles for collecting them in myproject/media/. I set
STATIC_ROOT (which is used by django-staticfiles) simply to
MEDIA_ROOT because I don't think a distinction is really
necessary.
(About the additional /myapp/ in the paths: This makes it easy for
the site admin to override some or all files.)
Settings: There is no really good solution for it. Django-Harness
seems to have found one, but I think clearly documenting them in
your app's documentation should be enough.
And of course, middleware, context managers, and URLs should be in
the app directory, too. Furthermore, an app should not have
login/logout ware, and if so, it should at least be easily
overridable in the global urls.py.
Use relative imports within the application's modules. They are
available since Python 2.5. This way, I avoided any tampering with
sys.path.
Tschö,
Torsten.
--
Torsten Bronger, aquisgrana, europa vetus
Jabber ID: torsten...@jabber.rwth-aachen.de
or http://bronger-jmp.appspot.com
Torsten Bronger writes:
> [...]
>
> I did some research on this two weeks ago and my impression was
> that there are no guidelines at all to create portable apps. On
> the contrary, the template path in the official Django tutorial is
... not a good example.