settings.py in Aldryn Django#
Aldryn continues to be supported by Divio, but we do not recommend using Aldryn Django for new applications.
Divio Django applications that use our addons framework are shipped with a
settings.py file that hooks into the
framework. The framework allows addon applications to configure their own settings programmatically.
At first sight, this
settings.py file may seem unusual, but in fact it behaves as a standard Django settings module.
INSTALLED_ADDONS lists the addons installed by the addons framework. The list is populated automatically:
on the Control Panel, when addons are added or removed
locally, when the
divio app developcommand is run
Items are inserted between the
<INSTALLED_ADDONS> tags. If you need to add items to the list manually while
developing, add them outside the tags, otherwise your changes will be overwritten the next time
develop is run.
INSTALLED_ADDONS = [ # <INSTALLED_ADDONS> ... # </INSTALLED_ADDONS> ]
Settings in Divio applications can either be configured automatically via the addons framework, or set manually.
Automatic settings loading#
Using this list of
import aldryn_addons.settings aldryn_addons.settings.load(locals())
section that follows checks each one for any settings that it has to apply. These settings will be loaded into the
settings module at this point. For example,
INSTALLED_APPS will be populated appropriately.
Any settings that have been loaded can be manipulated. For example, to add new applications to
you can add them in:
INSTALLED_APPS.extend([ # Extend the INSTALLED_APPS setting by listing additional applications here ])
It’s important to understand which settings are applied automatically.
If you declare a setting such as
aldryn_addons.settings.load(locals()), it may be
overwritten by the addon system.
If you declare it after
aldryn_addons.settings.load(locals()), it will overwrite any configuration performed by
the addon system, with possibly unpredictable results.
See Working with Django addons (legacy) for an overview of how settings are handled in general, and How to configure Django settings in Aldryn applications for advice on how to manipulate them.