Integration Patterns
Every integration follows one pattern: you set a typed field on DjangoConfig, and a
generator turns it into the matching Django settings. Nothing is registered by hand.
Settings generation
DjangoConfig.get_all_settings() runs SettingsOrchestrator.generate()
(django_cfg.core.generation). It builds the settings dictionary in dependency order:
- core, templates, static
- databases, caches
- security, email, logging, i18n, limits, sessions, testing
- third-party apps (admin site, Constance, Telegram)
- API (DRF, drf-spectacular, OpenAPI groups)
- OAuth, Django-RQ, Tailwind, payments
The result is computed once and cached on the config instance.
# api/settings.py
from .config import config
globals().update(config.get_all_settings())Where an integration lives
Each integration has one generator under django_cfg/core/generation/integration_generators/
(api.py, oauth.py, django_rq.py, sessions.py, tailwind.py, third_party.py).
The generator reads its config field and returns a settings fragment. The set of
installed apps and middleware comes from config.get_installed_apps() and
config.get_middleware().
| Config field | Generates |
|---|---|
openapi_client (OpenAPIClientConfig) | REST_FRAMEWORK, SPECTACULAR_SETTINGS and the per-group schema URLs |
django_rq (DjangoRQConfig) | RQ_QUEUES, worker and scheduler settings |
payments (PaymentsConfig) | CFG_PAYMENTS_OWNER_MODEL when the app is enabled |
admin_site (AdminSiteConfig) | CFG_ADMIN_SITE, read by CfgAdminSite |
DRF is reloaded after generation
DRF reads REST_FRAMEWORK once and caches it. If DRF was imported before django-cfg
generated its settings, the cache would hold the defaults, so get_all_settings() calls
reload_drf_api_settings() before it returns. Do not import rest_framework.settings
state yourself ahead of the config.
Adding your own settings
Anything django-cfg has no field for goes in settings.py after the generated values:
# api/settings.py
from .config import config
globals().update(config.get_all_settings())
MY_FEATURE_FLAG = TrueSee the OAuth and Django-RQ pages for two complete integrations.