django-dynconfig
Dynamic configuration management for Django. Store settings in the database, manage them through the admin, and access them with a simple API. Supports type casting, optional encryption for secrets, and caching.
Features
- Simple API —
get_config("key")from anywhere in your code - Typed values — Automatic casting to
str,int,float,bool,list, orjson - Admin UI — Manage configs in Django admin with grouping, search, and filtering
- Optional encryption — Encrypt sensitive values (API keys, secrets) at rest
- Caching — Uses Django's cache framework with automatic invalidation on save/delete
- Import/Export — Management commands to move configs between environments
Quick Start
pip install django-dynconfig
Add to your INSTALLED_APPS and run migrations:
# settings.py
INSTALLED_APPS = [
...
"dynconfig",
]
python manage.py migrate
That's it. Open the Django admin and start adding configurations, or use the API:
from dynconfig import get_config, set_config
# Set a config (creates it if it doesn't exist)
set_config("notifications.enabled", True)
set_config("billing.max_retries", 5)
set_config("billing.api_key", "sk_live_...", is_encrypted=True, group="billing")
# Get a config (typed automatically)
get_config("notifications.enabled") # → True (bool)
get_config("billing.max_retries") # → 5 (int)
get_config("billing.api_key") # → "sk_live_..." (decrypted)
get_config("missing.key", default=10) # → 10
Usage
Type Casting
Values are stored as strings in the database and cast to Python types on retrieval based on the value_type field:
| value_type | Python type | Example stored | Example returned |
|---|---|---|---|
string |
str |
"hello" |
"hello" |
integer |
int |
"42" |
42 |
float |
float |
"3.14" |
3.14 |
boolean |
bool |
"true" |
True |
json |
dict/list |
'{"a": 1}' |
{"a": 1} |
list |
list |
"a, b, c" |
["a", "b", "c"] |
When using set_config(), the type is auto-detected from the Python value if not specified.
Groups
Organize configs by group for cleaner admin views:
set_config("asaas.api_key", "...", group="billing")
set_config("asaas.webhook_secret", "...", group="billing")
# Get all configs in a group
from dynconfig import get_configs_by_group
billing = get_configs_by_group("billing")
# → {"asaas.api_key": "...", "asaas.webhook_secret": "..."}
Encryption
For sensitive values like API keys and secrets:
pip install django-dynconfig[encryption]
# settings.py
DYNCONFIG_ENCRYPTION_KEY = env("DYNCONFIG_ENCRYPTION_KEY")
Generate a key:
from cryptography.fernet import Fernet
print(Fernet.generate_key().decode())
Encrypted values are stored as ciphertext in the database and decrypted transparently on read. The admin shows •••••••• instead of the raw value.
Management Commands
# Export all configs to JSON
python manage.py exportconfigs -o configs.json
# Export only a specific group, excluding secrets
python manage.py exportconfigs -g billing --no-secrets -o billing.json
# Import configs (skip existing by default)
python manage.py importconfigs configs.json
# Import and overwrite existing
python manage.py importconfigs configs.json --overwrite
# Preview without changes
python manage.py importconfigs configs.json --dry-run
Settings
All settings are optional with sensible defaults:
| Setting | Default | Description |
|---|---|---|
DYNCONFIG_CACHE_BACKEND |
"default" |
Django cache backend to use |
DYNCONFIG_CACHE_TIMEOUT |
300 |
Cache TTL in seconds |
DYNCONFIG_CACHE_PREFIX |
"dynconfig" |
Cache key prefix |
DYNCONFIG_ENCRYPTION_KEY |
None |
Fernet key for encryption |
DYNCONFIG_RAISE_NOT_FOUND |
False |
Raise ConfigNotFoundError instead of returning None |
Django System Checks
Run python manage.py check to verify your configuration. dynconfig will warn you if encrypted config entries exist but DYNCONFIG_ENCRYPTION_KEY is not set.
License
MIT — see LICENSE.
Metadata
Release files for django-dynconfig 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django_dynconfig-0.1.0.tar.gz | 16.8 kB | With provenance | Details for django_dynconfig-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_dynconfig-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for django_dynconfig-0.1.0-py3-none-any.whl |
Total release size: 34.4 kB
Release files / django_dynconfig-0.1.0.tar.gz
| Download URL | django_dynconfig-0.1.0.tar.gz |
|---|---|
| Size | 16.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9cc4c3cf7ba9930fc88cefdef6a8d4a543acbb5da503bcdd4b44747c3faeb848
|
|
BLAKE2b-256 checksum How to use checksums |
6bdef25886c8d6fb6439c5fc153cdd35fc7547e431ec5fbb9190c9fd4f7eccc2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 3, 2026.
Transparency logRelease files / django_dynconfig-0.1.0-py3-none-any.whl
| Download URL | django_dynconfig-0.1.0-py3-none-any.whl |
|---|---|
| Size | 17.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8dc757914c8d53cc3425e113d50e4e756889f65a489e65839282c9aa477e16c0
|
|
BLAKE2b-256 checksum How to use checksums |
8e86cbed5d41554622407d93ed9e7ad9daa5b9a204926fabf00d341b9ce84ca0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 3, 2026.
Transparency logSecurity for django-dynconfig 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for django_dynconfig-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 3, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.