Addon configuration overview¶
Django applications may require or offer configuration options. Typically thiswill be achieved via the settings.py
file, or through environment variablesthat Django picks up.
This is largely handled by the aldryn_config.py in each application.
Divio Cloud projects offers both these methods, as well as configuration viathe Control Panel:
- Django settings
- environment variables
- addon configuration field
Environment variable, setting or Addon configuration field?¶
When should you adopt each of these methods in your applications?
Rules of thumb:
- For highly-sensitive configuration, such as passwords, use an environmentvariable - it’s safer, because it’s not stored in the codebase.
- For configuration that is specific to each instance of the codebase, or thatneeds to be different across Local, Test and Live environments,environment variables are recommended.
- For required configuration, it is a good idea to make it visible as a field,so it’s obvious to the user that it needs to be set; similarly if it’ssomething that a non-technical user might be expected to set.
- If you provide an addon configuration field, make sure it isn’t overridden byother configuration, as that could be confusing to the user.
- The settings.py file makes sense for configuration that isn’t sensitive,and will be the same in different instances of the codebase and can be thesame across the different environments.
- The cleaner you keep your settings.py, the better.
原文: http://docs.divio.com/en/latest/background/addon-configuration-overview.html