Configure¶
Once django-confit is installed, let’s configure it. This section describes directives related to django-confit in your Django settings.
CONFIT_SCHEMAS¶
A dictionary of <APP>: <SCHEMA>
where <APP>
is in
INSTALLED_APPS
and <SCHEMA>
is the Python dotted path to a Schema class
(or factory).
This configuration directive is mandatory only when you need configuration schemas that are not builtin django-confit. See also the list of builtin schemas.
validate_settings()
automatically loads schemas
from INSTALLED_APPS
setting. For each <APP> in INSTALLED_APPS
, it
looks for:
CONFIT_SCHEMAS[<APP>]
,django_confit.schemas.<APP>.ConfigurationSchema
.
Simple example from default settings in django-confit demo project [1]:
CONFIT_SCHEMAS = {
'django_confit_demo': 'django_confit_demo.settings_schemas'
'.DjangoConfitDemoConfigurationSchema'
}
Note
Early versions of django_confit tried to automatically load schemas, without having to register them:
settings_schemas.<APP>.ConfigurationSchema
in current package, to allow local overrides<APP>.settings_schemas.ConfigurationSchema
, to allow third-party applications to manage their own schema.django_confit.schemas.<APP>.ConfigurationSchema
to load django-confit‘s builtins.
The idea was nice. But it did not work. Because while trying to import
<APP>.settings_schemas.ConfigurationSchema
, if import <APP>
imports
Django stuff, then a circular import can occur. That is a pain to debug and
a pain to fix.
With a registry, we import only things that are expected to work.
Notes & references
[1] | https://github.com/benoitbryon/django-confit/blob/master/demo/django_confit_demo/default_settings.py |