Multi-Site Installation#

For operating multiple websites using the same virtualenv you can use copies of, and different versions of settings and the URL configuration for each site. You can use the same database for different websites or, if you want a stricter separation, different databases. You can define settings for all sites in a file that is imported in the site-specific settings, e. g. my_project/ At the end of these site-specific settings you can import local settings, which are not under version control, with SECRET_KEY, DATABASES, ALLOWED_HOSTS etc., which may be site-specific or not.

  1. Copy and edit and e. g. to and Change the reference to the settings like os.environ.setdefault("DJANGO_SETTINGS_MODULE", "my_project.settings_second_site"), if the settings are in my_project/ Do this for each site.

  2. In the site-specific settings import common base settings in the first line like from .base_settings import * and define SITE_ID, ROOT_URLCONF, CMS_LANGUAGES and other settings that should be different on the sites. This way all the items from the imported base settings can be overridden by later definitions:

    from .base_settings import *
    SITE_ID: int = 2
    ROOT_URLCONF: str = 'my_project.urls_second_site'
    # other site-specific settings…
    from .settings_local import *
  3. In the web server settings for a site you refer to the site-specific wsgi*.py like