Django applications in Fedora
David Malcolm
dmalcolm at redhat.com
Fri Mar 6 17:04:29 UTC 2009
On Fri, 2009-03-06 at 10:51 -0500, Ignacio Vazquez-Abrams wrote:
> So, here's what I did:
>
> 1) Move settings.py to /etc/%{name}/00-default.conf
> 2) Process django-settings.py.in (attached), replacing [[confpath]]
> with /etc/%{name}, and saving it as settings.py in the project root
> 3) Profit!
Nice.
I guess another way of doing it could have been to add something like
this to the apache config:
SetEnv DJANGO_SETTINGS_MODULE mysite.settings
SetEnv DJANGO_SETTINGS_CONFIG_DIR /etc/mysite
and then read that in the mysite/settings.py:
confpath = os.environ['DJANGO_SETTINGS_CONFIG_DIR']
conffiles = glob.glob(os.path.join(confpath, '*.conf'))
etc
(I just invented that latter env var)
I note your build seems to do some app-specific extraction of vars from
the tarball's settings.py and then overwrite that with the
post-postprocessed settings.py.in
> Well, it was a little more complex than that, but that's the gist of it.
> Full details here:
> http://ivazquez.fedorapeople.org/packages/transifex/transifex.spec
I notice you also set up SECRETKEY in %post
Are you packaging any apache config files? I didn't see anything
dropped in /etc/httpd/conf.d I guess you're separating the deployment
of the app code + data from the wiring of it up to a particular httpd
server.
A related issue is that Django doesn't seem to have a good way to
relocate all URLs in an app below a path. You can set django.root, but
unfortunately, this breaks all of the internal links.
http://www.djangobook.com/en/beta/chapter21/ notes "The (sic) all your
URL patterns will need to start with "/mysite/". For this reason we
usually recommend deploying Django at the root of your domain or virtual
host." TurboGears has a url() function for dealing with this, but I
haven't found an equivalent in Django yet.
Hope this is helpful
Dave
More information about the fedora-devel-list
mailing list