django-multi-domains

Django Middleware for mapping domains to custom url confs.


License
MIT
Install
pip install django-multi-domains==0.0.1

Documentation

django-multi-domains

This Django App sets specific URL Confs for configured domains.

After all, the app has only a small middleware.

Installation

pip install django-multi-domains

Setup

The following configurations should be added in the Django Settings Module.

  1. Add "multi_domains" to INSTALLED_APPS

    INSTALLED_APPS = [
        "...",
        "multi_domains",
    ]
  2. Add middleware "multi_domains.middleware.MultiDomainsMiddleware" to the beginning of the MIDDLEWARE

    MIDDLEWARE = [
        "multi_domains.middleware.MultiDomainsMiddleware",
        "...",
    ]
  3. Define the mapping of domain and urlconf MULTI_DOMAINS

    MULTI_DOMAINS = {
        "api.example.com": "api.urls",
        "shop.example.com": "shop.urls",
    }

If no mapping is set for a domain, ROOT_URLCONF is used as a fallback.