Aldryn Django (core Django)¶
Aldryn Django (
aldryn-django) is a wrapper application that installs and provides basic
configuration for Django.
See aldryn-django.aldryn_config (ensure that you switch to the correct branch) for the all settings it takes and how they are applied.
Most of the key settings are listed below.
Control Panel options¶
Some settings are exposed in the Aldryn Addon configuration form in the Control Panel. These
settings will take priority over those entered as environment variables or in
Hash static file names¶
The Aldryn Django addon includes a Hash static file names option. When selected, Django’s
ManifestStaticFilesStorage will be used as the storage
backend. This appends an MD5 hash of each file’s contents to its filename, allowing caching headers
to be safely set in the far future.
Aldryn Django configures uWSGI to set the
Cache-Control header to one year on files with a
hash in the filename.
Enables GeoDjango support. Adds
INSTALLED_APPS and sets the database
For local development you will need to edit
mdillon/postgis:9.4. On the Cloud, you will need to make a support request to have the new
database enabled for the project.
Remove URL language prefix for default language¶
When set, will add
aldryn_django.middleware.LanguagePrefixFallbackMiddleware to the middleware.
This will cause Django not to use a language prefix in the URL when serving the default
language. For example, by default,
/about will redirect to
/en/about if English is the
default language; with this option selected, it will not (and will instead redirect in the other
Note that prior to Django version 1.10, this will not work with projects in which multiple languages are defined.
This is a
302 Temporary Redirect, as determined in Django’s core. It is not
safe to use permanent redirects here, because language redirects are
content-dependent. A change in the site could cause redirect loops, as
described at 301 Permanent vs 302 Temporary redirects, or spurious 404 errors.
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 be
specified as an environment variable on the Live server (recommended) or in
Setting this manually will allow you to add the internal Divio domain of the
site, such as
example.eu.aldryn.io, to the domains that will redirect to
the primary domain. (You may wish to do this if you don’t want users or search
engines to discover your site at
example.eu.aldryn.io rather than
Note that if you specify
DOMAIN_REDIRECTS manually, you will need to list
all of its secondary domains, as it overrides the setting automatically
generated by the Control Panel.
By default, redirects are
302 Temporary Redirect. When
(where this is appropriate) will be
301 Permanent Redirect.
Can be specified as an environment variable (recommended) or in
See 301 Permanent vs 302 Temporary redirects for more information.
Cache control for static files¶
Static files in our Django projects are collected by Django at build time, and served by uWSGI.
Aldryn Django configures the command it issues to uWSGI to start static file serving on the basis
of project settings. By default, files are served with no
Cache-Control header applied.
STATICFILES_DEFAULT_MAX_AGE determines the
Cache-Control header value that uWSGI will
use for unhashed files (see the Hash static file names option, above). It is not recommended
to set this to high values, as the cached versions can continue to be used even after files
themselves have been updated.
On deployment, by default we check and update S3 media file headers. Occasionally this can cause
problems (for example, excessively long deployment times on very large media buckets). Setting this
True will skip this step on deployment.
Django server settings¶
See notes on
How to fine-tune your server’s performance.