Documentation: https://django-gc.rdd-lab.com/
Source Code: https://github.com/RDDLab/Django-GC
Django-GC stores typed runtime settings in the database and serves them from Django's cache. 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 after migrate.
- Typed values — strings, numbers, dates, arrays, choices, JSON, UUID, and optional secure secrets.
- Full cache snapshot —
get_value()never falls back to a single-row ORM read. - 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.
pip install django-gcINSTALLED_APPS = [
'django_gc',
'django.contrib.admin',
# ...
]Periodic refresh is optional:
pip install 'django-gc[celery]'In Django settings, set categories, keys, and the encryption key. Then migrate and read values through the service:
from enum import StrEnum
from django_gc import (
CategoryDefinition,
SettingDefinition,
SettingType,
get_value,
set_value,
)
class SettingKey(StrEnum):
MAINTENANCE_ENABLED = '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,
),
]
GLOBAL_CONFIG_ENCRYPTION_KEY = 'replace-with-a-long-random-secret'
enabled = get_value(SettingKey.MAINTENANCE_ENABLED)
set_value(SettingKey.MAINTENANCE_ENABLED, True)