django links
Starting at /home/work/django
media/
(common media files and folders)
(soft links to real media folders)
templates/
(common templates)
apps/
blog/
media/
templates/
photogallery/
media/
templates/
sites/
site1/
config/
settings.py
urls.py
manage.py
site2/
config/
settings.py
urls.py
manage.py
site1 vhost config is as follows (using apache 2.0 and mod_python)
<VirtualHost *:80>
ServerName site1
<Location "/">
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE config.settings
PythonPath "['/home/work/django/apps',
'/home/work/django/sites/site1'] + sys.path"
</Location>
Alias /media "/home/work/django/media"
<Directory "/home/work/django/media">
Options Indexes FollowSymLinks
Order allow,deny
Allow from all
</Directory>
RewriteRule ^/media$ /media/ [R]
<Location "/media/">
SetHandler None
</Location>
</VirtualHost>
site2 vhost config:
(Same as above, changing ServerName and PythonPath)
You don't need to make soft links in apps template folders if you configure
properly settings.py:
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.load_template_source',
'django.template.loaders.app_directories.load_template_source', # :-)
)
This layout works because we use the same server machine for django and
static files. Probably in a more optimized environment you will need to copy
application media folders to the static content server.
-- DetlevLengsfeld 2007-09-24 05:24:07
Python/Django/Der optimale Aufbau mit reusable Code und apache vhost (last edited 2009-09-29 06:04:26 by DetlevLengsfeld)