Automatic configuration of a Django project based on the requirements of apps in the INSTALLED_APPS setting.
Import django_autoconfig.autoconfig in settings.py, and call configure_settings with globals():
from django_autoconfig.autoconfig import configure_settings
configure_settings(globals())
django-autoconfig will run through each app in INSTALLED_APPS, applying the configuration in their autoconfig module.
Note
configure_settings must be run after INSTALLED_APPS is defined.
In your app, define a autoconfig module, that contains the settings you need defined, or the app’s requirements:
SETTINGS = {
'MY_APP_MUST_HAVE_THIS_VARIABLE_SET': False,
}
If your app requires a particular ordering of the values in a setting, you can define a list of django_autoconfig.autoconfig.OrderingRelationship objects specifying these relationships.
Bases: builtins.object
This class defines a relationship between an element in a setting that’s a list and one or more other entries.
It’s intended to be used in an autoconfig.py file like so:
RELATIONSHIPS = [
OrderingRelationship(
'INSTALLED_APPS',
'my.app',
before = [
'django.contrib.admin',
],
after = [
],
)
]
If autoconfig cannot reach a consistent state, an ImproperlyConfigured exception will be raised. This means that two or more apps could not agree on the required settings, and this must be manually reserved.