django-extra-settings
raw JSON → 0.14.1 verified Fri May 01 auth: no python
Manage typed extra settings via Django admin. Current version 0.14.1, release cadence irregular with major upgrades for Django/Python support.
pip install django-extra-settings Common errors
error ModuleNotFoundError: No module named 'jsonfield' ↓
cause As of v0.13.0, the jsonfield dependency was removed and replaced with models.JSONField. If your requirements pin an old version, you get this error.
fix
Upgrade to v0.13.0+ or keep jsonfield in requirements if sticking with older version.
error You have 18 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): extra_settings. ↓
cause Missing database migration for the extra_settings app.
fix
Run 'python manage.py migrate extra_settings' to apply migrations.
error AttributeError: 'Settings' object has no attribute 'get_setting' ↓
cause Trying to use extra_settings.get_setting but confused the import (maybe imported the class instead of the module).
fix
Use 'from extra_settings import extra_settings' (lowercase) then extra_settings.get_setting(...).
Warnings
breaking Dropped Python 3.8/3.9 and Django 3.x support in v0.13.0. Upgrade to Python 3.10+/Django 4.2+. ↓
fix Update to Python >=3.10 and Django >=4.2
breaking Removed jsonfield dependency; now uses built-in models.JSONField. Existing migrations may need update. ↓
fix If you have custom migrations referencing jsonfield, update to use Django's JSONField.
gotcha The cached value of settings is only cleared on app ready; if you change a setting manually in code, you must clear cache. ↓
fix Use Setting.objects.clear_cache() or extra_settings.clear_cache() after manual changes.
Imports
- extra_settings wrong
from django_extra_settings import settingscorrectfrom extra_settings import extra_settings - Setting wrong
from extra_settings import Settingcorrectfrom extra_settings.models import Setting
Quickstart
import os
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myproject.settings')
import django
django.setup()
from extra_settings.models import Setting
# Create a string setting with a default value
obj, created = Setting.objects.get_or_create(
name='MY_SETTING',
defaults={
'value_type': 'string',
'description': 'My custom setting',
'default_value': 'default',
'enabled': True
}
)
print(f"Setting MY_SETTING = {obj.current_value}")
# Or use the getter
from extra_settings import extra_settings
print(extra_settings.get_setting('MY_SETTING', default='fallback'))