django-config-models
raw JSON → 3.0.0 verified Mon Apr 27 auth: no python
A Django library providing configuration models with auditing capabilities, enabling management of dynamic site configuration through database-backed models. Version 3.0.0 is the latest, actively maintained by the Open edX community. Releases are irregular but stable.
pip install django-config-models Common errors
error ModuleNotFoundError: No module named 'configuration_models' ↓
cause Deprecated import path.
fix
Use 'config_models' instead: from config_models.models import ConfigurationModel
error django.core.exceptions.ImproperlyConfigured: Requested setting, but settings are not configured. ↓
cause Django settings not loaded before using models.
fix
Ensure Django is fully set up before importing config models. In scripts, use django.setup() after configuring settings.
error config_models.models.ConfigurationModel.MultipleObjectsReturned: get() returned more than one ConfigurationModel -- it returned 2! ↓
cause More than one active configuration record exists (e.g., multiple enabled=True).
fix
Ensure only one record has enabled=True for each unique key or use .current() which handles conflicts.
Warnings
breaking In v3.0.0, Django 3.2 support dropped; requires Django >=4.2. ↓
fix Upgrade Django to 4.2 or later.
deprecated Old import path 'configuration_models' is deprecated; use 'config_models'. ↓
fix Change import to 'from config_models.models import ConfigurationModel'.
gotcha ConfigurationModel uses an audit log; every save creates a new historical record. Avoid calling .save() in loops. ↓
fix Use bulk operations or update only when necessary.
Imports
- ConfigurationModel wrong
from configuration_models.models import ConfigurationModelcorrectfrom config_models.models import ConfigurationModel
Quickstart
from config_models.models import ConfigurationModel
from django.db import models
class MyConfig(ConfigurationModel):
key = models.CharField(max_length=255, unique=True)
value = models.TextField()
# Usage
config = MyConfig.current()
print(config.value)