Stay informed of it
Project description
Django Dynamic Settings
Django Dynamic Settings allows you to create & use dynamic settings backed by a database.
Installation
Installation using pip:
pip install dj-dynamic-settings
dj_dynamic_settings
app has to be added to INSTALLED_APPS
and migrate
command has to be run.
INSTALLED_APPS = (
# other apps here...
"dj_dynamic_settings",
)
dj_dynamic_settings.urls
must be included to a desired url path.
urlpatterns = [
...,
url(r"^api/v1/", include("dj_dynamic_settings.urls")),
]
Setting class must be defined & registered. Please make sure that this class' module runs whenever the application runs.
from dj_dynamic_settings.registry import BaseSetting, registry
from dj_dynamic_settings.validators import TypeValidator
@registry.register
class FeatureActive(BaseSetting):
key = "FEATURE_ACTIVE"
validators = [TypeValidator(bool)]
default = False
description = "Flag for Feature X"
Create Setting
instance using view.
import requests
requests.post(
url="https://your-app.com/api/v1/dynamic_settings/",
headers={
"Authorization": "Token <secret-login-token>",
},
json={
"key": "FEATURE_ACTIVE",
"value": True,
"is_active": True,
}
)
Access this setting as in django.conf.settings
from dj_dynamic_settings.conf import settings
settings.FEATURE_ACTIVE # True
Testing Tools
override_settings()
You can override a setting for a test method or test class.
from dj_dynamic_settings.utils import override_settings
from django.test import TestCase
@override_settings(SOME_SETTING="some_setting")
class FeatureTestCase(TestCase):
@override_settings(SOME_OTHER_SETTING="SOME_OTHER_SETTING")
def test_feature(self):
# Some stuff
pass
def test_feature_x(self):
with override_settings(SOME_OTHER_SETTING="SOME_OTHER_SETTING"):
# Some stuff
pass
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
dj-dynamic-settings-0.1.7.tar.gz
(13.5 kB
view hashes)
Built Distribution
Close
Hashes for dj-dynamic-settings-0.1.7.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0bfb2b117621fae3e4f1dd0dfc073615086744551daf428749fa5a8b4444fa10 |
|
MD5 | f4e1ebdea17e9d2e085e746797488ced |
|
BLAKE2b-256 | 0a713792793aaf7b0edebe1703e77b33caacae03de7c3fd3fd03a3e65615c276 |
Close
Hashes for dj_dynamic_settings-0.1.7-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 20239c472a08cefb5720e64cfe5f8c0f4cd55df9f8e668f776e9f8cfff60638d |
|
MD5 | 10f48d0649a1a04c63e68513e415b3ff |
|
BLAKE2b-256 | c37b8e89a0dad7a5e71aba5b0f07b67ee0318eb91411346cb076065aa3e5136b |