Skip to main content

use dynamic (database) settings in your settings.py

Project description

django-dynamicsettings

tests Test coverage status Current version on PyPi monthly downloads PyPI - Python Version PyPI - Django Version

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-dynamicsettings-0.0.3.tar.gz (6.7 kB view hashes)

Uploaded Source

Built Distribution

django_dynamicsettings-0.0.3-py3-none-any.whl (7.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page