Skip to main content

django-multisite supporto for django CMS

Project description

django-multisite support for DjangoCMS

Join the Gitter chat Latest PyPI version Python versions Latest Travis CI build status Test coverage Test coverage Code Climate License

Support

Supported Django versions:

  • Django 3.0

  • Django 2.2

Supported django CMS versions:

  • django CMS 3.7

Assumptions

  1. A virtualenv up and running

  2. DjangoCMS working

Installation

pip install djangocms-multisite

Usage

  1. Open your settings.py file

  2. We need to add the configurations for django-multisite :

    • Replace SITE_ID value with the SiteID function:

      from multisite import SiteID
      SITE_ID = SiteID(default=1)
    • Add multisite, djangocms_multisite to INSTALLED_APPS:

      INSTALLED_APPS=[
          ...
          'multisite',
          'djangocms_multisite',
          ...
      ]
    • Add those loders in the TEMPLATES setting:

      TEMPLATES = [
          ...
          {
              ...
              'DIRS': {...}
              'OPTIONS': {
                  'loaders': (
                      'multisite.template.loaders.filesystem.Loader',
                      'django.template.loaders.app_directories.Loader',
                  )
              }
              ...
          }
          ...
      ]
    • For other settings (cache, etc.) check the django-multisite page

  3. Add multisite.middleware.DynamicSiteMiddleware and djangocms_multisite.middleware.CMSMultiSiteMiddleware to MIDDLEWARE_CLASSES. The order is important: multisite.middleware.DynamicSiteMiddleware must be applied before cms.middleware.utils.ApphookReloadMiddleware, while djangocms_multisite.middleware.CMSMultiSiteMiddleware must be right after:

    MIDDLEWARE_CLASSES = [
        ...
        'multisite.middleware.DynamicSiteMiddleware',
        'cms.middleware.utils.ApphookReloadMiddleware',
        'djangocms_multisite.middleware.CMSMultiSiteMiddleware',
        ...
    ]
  4. Configure the URL mapping as follows. The tests.test_utils.urls1 path can be the main urlconf file that you already have in your project. And it can be the same for all the domains if you need the same structure.:

    MULTISITE_CMS_URLS={
        'www.example.com': 'tests.test_utils.urls1',
        'www.example2.com': 'tests.test_utils.urls2',
    }
    MULTISITE_CMS_ALIASES={
        'www.example.com': ('alias1.example.com', 'alias2.example.com',),
        'www.example2.com': ('alias1.example2.com', 'alias2.example2.com',),
    }
    MULTISITE_CMS_FALLBACK='www.example.com'
  5. Run python manage.py makemigrations

  6. Run python manage.py migrate to apply the django-multisite migrations

Settings explanation

MULTISITE_CMS_URLS

Dictionary (or OrderedDict) containing the mapping between the domain (as configured in django sites) and the corresponding urlconf.

MULTISITE_CMS_FALLBACK

The default domain to load if any of the above does not match.

MULTISITE_CMS_ALIASES

Dictionary (or OrderedDict) containing the mapping between the domain (as configured in django sites) and a list of aliases. This is optional if all the aliases are configured as django-multisite aliases

Troubleshooting

  • Domains in MULTISITE_CMS_URLS must be the same created in your database (via the interface in Home › Sites › Sites).

History

0.3.1 (unreleased)

  • Fix history formatting preventing proper pypi release

0.3.0 (2020-07-05)

  • Add Django 2.2 / django CMS 3.7+ support

  • Drop older Django / django CMS versions

0.2.0 (2018-09-25)

  • Add Django 1.11 / django CMS 3.4+ support

  • Drop older Django / django CMS versions

  • Improve documentation

0.1.0 (unreleased)

  • First experimental release

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

djangocms-multisite-0.3.1.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

djangocms_multisite-0.3.1-py2.py3-none-any.whl (5.5 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file djangocms-multisite-0.3.1.tar.gz.

File metadata

  • Download URL: djangocms-multisite-0.3.1.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.3

File hashes

Hashes for djangocms-multisite-0.3.1.tar.gz
Algorithm Hash digest
SHA256 d90da8424db2f749b9a27263393678ebb56baf1702d27c6b20d9dfb03843cd76
MD5 f31a7e86d7cea4bc287dfbaa9ac573e1
BLAKE2b-256 6d15a97886a281e95d11908b13cf7b05965daaf5ff1c18097126823b2257b15a

See more details on using hashes here.

File details

Details for the file djangocms_multisite-0.3.1-py2.py3-none-any.whl.

File metadata

  • Download URL: djangocms_multisite-0.3.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.3

File hashes

Hashes for djangocms_multisite-0.3.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 225fa1cb88387e6444a7be9e9aef89bda5964101737e823e781235a6fbbf35b0
MD5 ea7a64357f6438b7aaacdddf25c39486
BLAKE2b-256 8c41aee8d14c8225ec583666d74a7fd482163eb8e8ee72d92193b4567f114e42

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page