An extension for django.contrib.sites, featuring domain redirects and automatic population of the django.contrib.sites.Site table based on settings.
Project description
Extensions to django.contrib.sites.
Features
Domain redirects: handles smart redirecting to a main domain from alias domains. Taking http/https into consideration.
Site auto-population: automatically populates the Domain name in django.contrib.sites.Site.domain based on the ALDRYN_SITES_DOMAINS setting.
Installation
add aldryn_sites to INSTALLED_APPS. add aldryn_sites.middleware.SiteMiddleware to MIDDLEWARE_CLASSES (place it before djangosecure.middleware.SecurityMiddleware if redirects should be smart about alias domains possibly not having a valid certificate of their own. The middleware will pick up on SECURE_SSL_REDIRECT from django-secure.)
configure ALDRYN_SITES_DOMAINS:
ALDRYN_SITES_DOMAINS = { 1: { # matches SITE_ID 'domain': 'www.example.com', # main domain that all the aliases will redirect to. # Auto populates ``django.contrib.sites.Site.domain`` 'aliases': [ # these domains will be redirected to the main domain. 'example.com', # add ``'*'`` to redirect all non-main domains to the main one. 'example.ch', 'www.example.ch', ] } }
Further Settings
set ALDRYN_SITES_SET_DOMAIN_NAME to False if you don’t want django.contrib.sites.Site.domain to be auto-populated (default: True).
TODOS
validate settings
test settings validators
log warning if there are Sites in the database that are not in the settings
pretty display of how redirects will work (in admin and as a simple util)
regex support for aliases
form to test redirect logic
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file aldryn-sites-0.2.tar.gz
.
File metadata
- Download URL: aldryn-sites-0.2.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3c212a1001c123cd04c3f54df453db41c5ccaf473a24d452411ded8e3ad5ddb8 |
|
MD5 | 2cee1f8a05c5ec329ea6c05f635addec |
|
BLAKE2b-256 | e2079eb044248281a0148c1d459c2a5c6e3e546492f7f054c8e43a2c5c30d063 |