Basics🔗
Environments are defined with a simple class-based configuration in the settings.py
module.
The Environment must be selected by setting the DJANGO_SETTINGS_ENVIRONMENT
environment variable
to the name of the class. If the environment variable is not set, an exception will be raised,
since the library will not be able to determine which environment should be used.
Similarly to the django-configurations library, the selected Environment's upper-case class attributes will be added as the module level global variables in the module where the environment is defined. This happens immidiately after the Environment class is defined as part of the class creation process.
However, this library's implementation is much simpler and doesn't require any
additional configuration or setup. Here is the magic behind the scenes from
env_config.base.Environment.setup
:
Of course, one should be a little careful that this does not override any existing global variables in the module.