Multisite

Hi,

I would like to add multisite support in my dev site. Haven’t found much help on the web. Can anybody point to a resource where I can get some guidance?

Basically I would like to create pages for different sites, and then let the platform point to one or another based on that, however I created a site2 in my test deployment and created a page1 for site2, however that doesn’t seem to work. Whenever I point to domain2, I get all the pages from domain1 aswell.

Thanks in advance for your help.

Carlos.

Hi,
for the multisite to actually work, you need to split the django config into two or more parts having different SITE_ID, and then run the servers on different ports for connecting to different domains, or to do something similar.

In order not to duplicate the entire setting file, you may rename settings.py to commonsettings.py,
and create settings_1.py and settings_2.py looking like this:

settings_1.py:

from cms.commonsettings import *

SITE_ID = 1

Then run it using commands

manage.py runserver 6001 --settings=cms.settings_1
manage.py runserver 6002 --settings=cms.settings_2

And connect to different domains in nginx.

Of cause, for production environment wsgi interface is needed, but the general idea remains.
Hope it helps.

Alex

2 Likes

And since the wsgi files point to the settings, you have to adopt them like so:

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "cms.settings_1")