tags:

views:

31

answers:

2

Hi,

I am planning to have multiple site running from one Django Codebase using Apache + mod_wsgi. Could anyone please help me in achieving this.

A: 

Use different settings modules.

Ignacio Vazquez-Abrams
Hi,Could you please elaborate. I need to dynamically import the site specific settings files into the global setting file. Could you please help me how can I achieve this with Apache + mod_wsgi
Joseph
Import the global settings in the site-specific settings.
Ignacio Vazquez-Abrams
A: 
  • every Django project should have it's own mod.wsgi file (not necessarily called mod.wsgi, btw) which looks like :

    import os, sys
    sys.path.append('DJANGO_PATH')
    sys.path.append('DJANGO_PATH/SITEPATH')
    os.environ['DJANGO_SETTINGS_MODULE'] = 'SITE.settings'
    
    
    import django.core.handlers.wsgi
    application = django.core.handlers.wsgi.WSGIHandler()
    

    where DJANGO_PATH is the path where all your Django projects were created, SITEPATH is the folder where your specific project resides.

  • in Apache make a virtualhost for every site that refers to their own mod.wgsi files, like :

    WSGIScriptAlias / /DJANGOPATH/SITEPATH/mod.wsgi
    

repeat for all sites.

Jasper
ok agreed, but consider if I need a common authentication technique need to be applied for these two sites. how can I achieve this without replicating the code and resource. These two sites may be using its own database and the authentication User table is supposed to be a different database. Is there a way to achieve this. Please advice
Joseph
You could use a LDAP database to authenticate against. In the settings.py file in each project you can set the databases for the application data. In that case their both not used for authentication/user data.
Jasper