On 17/04/2018 8:51 PM, sbarnett wrote:
What is the best way to structure multiple settings files when using the Sites framework?

I've already got a base settings file along with a local, staging and production file which inherits from this and makes some changes/additions.

But now I need to use the Sites framework so I need another bunch of files that set the relevant SITE_ID, change the TEMPLATES directory etc.

I'm just not sure how to lay all of this out so that the site settings files can inherit (and then potentially override) the correct settings from local, staging or production.

I ship staging.py (has SITE_ID = 2)  and production.py (has SITE_ID = 1) to both machines and use wsgi.py to select the correct one. Here is mine ...

import os
import sys
from socket import gethostname

from django.core.wsgi import get_wsgi_application

# hard coded paths in buildbot master.cfg
project = "ssds"
srvroot = "/var/www"
site_root = "%s/%s" % (srvroot, project)   # as per bot master.cfg

hname = gethostname()
if "pq4" in hname:
    site = "production"
elif "pq3" in hname:
    site = "staging"
else:
    site = "dev"

if site_root not in sys.path:
    sys.path.insert(0, site_root)

os.environ["DJANGO_SETTINGS_MODULE"] = "%s.settings.%s" % (project, site)
os.environ["PYTHON_EGG_CACHE"] = site_root

# this is the public API - returns django.core.handlers.wsgi.WSGIHandler()
application = get_wsgi_application()






Any ideas?
--
You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com <mailto:django-users+unsubscr...@googlegroups.com>. To post to this group, send email to django-users@googlegroups.com <mailto:django-users@googlegroups.com>.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f72d6853-e16d-4d82-b2f5-fede38ea9f63%40googlegroups.com <https://groups.google.com/d/msgid/django-users/f72d6853-e16d-4d82-b2f5-fede38ea9f63%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f904d6b6-dd3d-b243-b1e7-035bb457726d%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.

Reply via email to