Skip to content

Repository files navigation

Logo

License: MIT Ruff pyrefly PyPI PyPI pyversions PyPI djversions PyPI status PyPI - Downloads PyPI - Types


Tests Codecov pre-commit.ci status


Documentation: https://django-gc.rdd-lab.com/

Source Code: https://github.com/RDDLab/Django-GC


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.

Features

  • 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 snapshotget_value() never falls back to a single-row ORM read.
  • Stock Django Admin — edit values with standard ModelAdmin and Django's built-in change history.
  • Optional Celery — periodic full snapshot refresh.
  • Fully typed — ships py.typed; compatible with pyrefly and standard type checkers.

Installation

pip install django-gc
INSTALLED_APPS = [
    'django_gc',
    'django.contrib.admin',
    # ...
]

Periodic refresh is optional:

pip install 'django-gc[celery]'

Quick start

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)

Documentation

https://django-gc.rdd-lab.com/

About

Django extension for creating and managing global application configuration

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages