On 18/04/2018 6:09 PM, Simon Barnett wrote:
Ah, I think you've slightly misunderstood me.

I already have staging and production sites and settings files - I don't use the Sites framework for that - I just use the DJANGO_SETTINGS_MODULE to control which settings file to use.

But now, I need to start using the Sites framework to serve mutliple (live) sites using the same code and database. So a.com and b.com, both displaying different data from the same database.

For this, I think I'll need a settings file for each site - a.py and b.py - which define the SITE_ID and templates dir for each one. But then, how do I structure all these settings files I now have?

base.py - main settings
staging.py - staging settings
production.py - production settings
a.py - settings for a.com
from production import *

b.py - settings for b.com
from production import *

and how do I use them for local development?

dev-a.py
from a import *

dev-b.py
from b import *



On Wednesday, 18 April 2018 04:53:56 UTC+1, Mike Dewhirst wrote:

    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...@googlegroups.com <javascript:>
    > <mailto:django-users+unsubscr...@googlegroups.com <javascript:>>.
    > To post to this group, send email to django...@googlegroups.com
    <javascript:>
    > <mailto:django...@googlegroups.com <javascript:>>.
    > Visit this group at https://groups.google.com/group/django-users
    <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>

    >
    
<https://groups.google.com/d/msgid/django-users/f72d6853-e16d-4d82-b2f5-fede38ea9f63%40googlegroups.com?utm_medium=email&utm_source=footer
    
<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
    <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 <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/07686134-881e-4bb0-aff9-fb35b9e4f988%40googlegroups.com <https://groups.google.com/d/msgid/django-users/07686134-881e-4bb0-aff9-fb35b9e4f988%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/4d499445-5d3d-7a85-1656-77771c3d5ea8%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.

Reply via email to