use dynamic (database) settings in your settings.py
Project description
django-dynamicsettings
Django app to allow (chosen) settings to be configurable through django admin (or anything that updates the Settings model).
Usage
In your settings.py
(or whatever DJANGO_SETTINGS_MODULE you are using), simply change:
MIGHTY_SETTING = 'boring_setting_requires_deploy'
to
from dynamicsettings import DynamicSetting as DYN
MIGHTY_SETTING = DYN('boring_setting_requires_deploy')
And done. MIGHT_SETTING
value can now be changed using dynsetting.Setting
model (registered in django-admin).
DynamicSetting
class caches the values from database as, quite often, the settings are accessed many times in the same loop.
There is CACHE_TTL
setting to control it (default being 1
second).
To change it simply put
from dynamicsettings import DynamicSetting as DYN
DYN.CACHE_TTL = 30
in that same settings module. 0
disables cache entirely (not recommended).
Alternatives
https://django-dynamic-preferences.readthedocs.io/en/latest/ seems like a popular solution to this problem but it solves it differently.
You need to register the settings with those decorators while with dynamicsettings
you just add an helper to your usual settings.py definition and everything should seamlessly works!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file django-dynamicsettings-0.0.3.tar.gz
.
File metadata
- Download URL: django-dynamicsettings-0.0.3.tar.gz
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3c7cc95a6a99e61dccd7b9c371a1f60826a5e36453a903d7e9e4f9dbdf543a4b |
|
MD5 | 44902ecd40a1b74c36f11e05f9d16a5a |
|
BLAKE2b-256 | 95d9409d72832d0321709423ca6d00f5e4378ed040ed81bfe6329b4491122bb8 |
File details
Details for the file django_dynamicsettings-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: django_dynamicsettings-0.0.3-py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cecff91178c460b6ab0b9c38b0fcea452b2bd01b97e0d3f5c2ad7c3385494d6a |
|
MD5 | 74f850679d4c5dbc4566cbc29e99d66f |
|
BLAKE2b-256 | 68fd816af05f10f3eee33837be87f4739220edd912d94dfd4cb9cc820eaff93c |