How can Django use different settings.py file based on subdomains.
Can these utilities ("django-admin", "python manage.py") still be used if there were different settings connecting to different databases.
How can Django use different settings.py file based on subdomains.
Can these utilities ("django-admin", "python manage.py") still be used if there were different settings connecting to different databases.
ok you have two dimensions you need to cover with your settings:
Here is what I recommend:
universal_settings.py
- all the settings you want to inherit everywhere (all machines, all domains)
local_settings.py
- settings on a per machine basis (database settings, mail server, etc)
site_1.py
- settings that are specific to a one of your domains
site_2.py
- settings that are specific to a one of your domains
site_n.py
- you get the idea
the bottom of universal_settings.py should include:
from local_settings import *
This will override anything in the universal settings as necessary.
similarly, each of the site_1.py
, site_2.py
, site_n.py
settings files should begin with:
from universal_settings import *
Finally you need to set up an apache (or nginx, or whatever) instance for each domain and use the appropriate site_n.py
as the settings file for that server
This is the method that works best for me :)