Documentation: https://django-gc.rdd-lab.com/
Source Code: https://github.com/RDDLab/Django-GlobalConfig
Django-GC stores typed runtime settings in the database and uses a shared cache when configured. Application code never reads a value through the ORM. The project owns the keys; this package is the mechanism.
- Code-declared keys — categories and definitions live in Django settings and are synchronized by
initialize_global_configs. - Typed values — strings, numbers, dates, arrays, choices, JSON, UUID, and optional secure secrets.
- Targeted cache updates — saving one setting refreshes only its typed cache entry.
- Full recovery snapshot — a miss in a shared cache rebuilds the snapshot.
- Direct database reads — local-memory and dummy caches use current values from the database.
- Stock Django Admin — edit values with standard
ModelAdminand Django's built-in change history. - Optional Celery — periodic full snapshot refresh.
- Fully typed — ships
py.typed; compatible with pyrefly and standard type checkers.
| Python | Minimum Django |
|---|---|
| 3.12, 3.13, 3.14 | 6.0 |
| 3.15 | 6.1.3 |
pip install 'django-gc>=1.1.6'INSTALLED_APPS = [
'django_gc',
'django.contrib.admin',
# ...
]Periodic refresh is optional:
pip install 'django-gc[celery]'Declare categories and keys in Django settings. Set the encryption key through your deployment configuration before using SECURE values.
from enum import StrEnum
from django_gc import (
CategoryDefinition,
SettingDefinition,
SettingType,
)
class SettingKey(StrEnum):
MAINTENANCE_ENABLED = 'platform.maintenance_enabled'
GLOBAL_CONFIG_CATEGORIES = [
CategoryDefinition(id=1, code='platform', name='Platform'),
]
GLOBAL_CONFIG_DEFINITIONS = [
SettingDefinition(
key=SettingKey.MAINTENANCE_ENABLED,
description='Maintenance mode',
default_value=False,
value_type=SettingType.BOOLEAN,
category_id=1,
),
]python manage.py migrate
python manage.py initialize_global_configsAfter Django has initialized, use the runtime API from application code.
from django_gc import get_value, set_typed_value
enabled = get_value("platform.maintenance_enabled")
set_typed_value(key="platform.maintenance_enabled", value=True)Getting started · Upgrade and operations · Documentation deployment
После создания схемы и при обновлении definitions выполните uv run python manage.py initialize_global_configs. Миграции не создают категории и значения GC. Существующие значения сохраняются.
The metadata template uses the standard Django template loader. Project templates may override its logical name.