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.
-
Add
"multi_domains"
toINSTALLED_APPS
INSTALLED_APPS = [ "...", "multi_domains", ]
-
Add middleware
"multi_domains.middleware.MultiDomainsMiddleware"
to the beginning of theMIDDLEWARE
MIDDLEWARE = [ "multi_domains.middleware.MultiDomainsMiddleware", "...", ]
-
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.