Aldryn Django (core Django)¶
Aldryn Django (aldryn-django
) installs and provides basic configuration for Django.
Key Aldryn Django configuration options¶
Remove URL language prefix for default language¶
Set on the Aldryn Django configuration on the Control Panel.
When set, will add the aldryn_django.middleware.LanguagePrefixFallbackMiddleware
to themiddleware.
This will cause Django not to use a language prefix in the URL when serving the defaultlanguage. For example, by default, /about
will redirect to /en/about
if English is thedefault language; with this option selected, it will not (and will instead redirect in the otherdirection).
Note that prior to Django version 1.10, this will not work with projects in whichmultiple languages are defined.
This is a 302 Temporary Redirect
, as determined in Django’s core. It is notsafe to use permanent redirects here, because language redirects arecontent-dependent. A change in the site could cause redirect loops, asdescribed at 301 Permanent vs 302 Temporary redirects, or spurious 404 errors.
SECURE_SSL_REDIRECT¶
When True
, redirects to the HTTPS version of the site.
Can be specified as an environment variable (recommended) or in settings.py
.
The SECURE_SSL_REDIRECT setting ishandled by Django’s SecurityMiddleware
.
By default, this is a 302 Temporary Redirect
DOMAIN_REDIRECTS¶
A list of domain names that will redirect to the site’s primary domain name.
By default, this is populated by the Control Panel. If required, it can also bespecified as an environment variable on the Live server (recommended) or insettings.py
.
Setting this manually will allow you to add the internal Divio domain of thesite, such as example.eu.aldryn.io
, to the domains that will redirect tothe primary domain. (You may wish to do this if you don’t want users or searchengines to discover your site at example.eu.aldryn.io
rather thanexample.com
.)
Note that if you specify DOMAIN_REDIRECTS
manually, you will need to listall of its secondary domains, as it overrides the setting automaticallygenerated by the Control Panel.
ALDRYN_SITES_REDIRECT_PERMANENT¶
By default, redirects are 302 Temporary Redirect
. When True
, redirects(where this is appropriate) will be 301 Permanent Redirect
.
Can be specified as an environment variable (recommended) or in settings.py
.
See 301 Permanent vs 302 Temporary redirects for more information.
Other options¶
See aldryn-django.aldryn_configfor the settings it takes and how they are applied. (Check that you arereferring to the appropriate version.)
原文: http://docs.divio.com/en/latest/reference/addons-aldryn-django.html