| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Multisite support for feincms3.
Suppose you have a website with several domains and languages but an exact 1:1 mapping between them. Django offers the django.contrib.sites application to partition data but you still have to run one webserver per site.
This app offers a feincms3 abstract page model, a middleware and utilities to support this scenario. Contrary to feincms3-sites which is even more flexible and allows arbitrary combinations of languages and domains this app only allows exactly one domain per language and exactly one language per domain.
Possible configuration:
SITES = {
"de": {
"host": "127.0.0.1:8000",
"host_re": r"example\.com$|127.0.0.1:8000$",
},
"fr": {
"host": "localhost:8000",
},
}Sites are checked in the order they are declared (since dictionaries are guaranteed to preserve the ordering of keys since Python 3.7).
The keys of the SITES dictionary have to be equal to all language codes in LANGUAGES. The host is required and should only consist of the host and an optional port, nothing else. If host_re is given the request.get_host() return value is matched against the host_re regular expression, otherwise the host has to match exactly.
The site_middleware automatically raises a DisallowedHost exception if no site matches the current request (which produces the same error as Django if the request doesn't match ALLOWED_HOSTS).
Note that Page.objects.active() only returns pages in the current language. If you want to generate translation links (e.g. using ...|translations in a template) you do not want to use the .active() queryset method but build something yourself which runs .filter(is_active=True).
| Back | FazBrowse Home | New Git URL |