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.3.tar.gz
(13.5 kB
view hashes)
Built Distribution
Close
Hashes for dj-dynamic-settings-0.1.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4c2e9cc995a2dc768985c4def7e8117c89b2c09f6afa6b2e903781f3a8cb1404 |
|
MD5 | fe0ec4695bf7f1acd1eb1c0eb069eb54 |
|
BLAKE2b-256 | 5e76ec64b74117e34c70bf87d4c6c4efbfdeb7663ba2223ae011428d29049c54 |
Close
Hashes for dj_dynamic_settings-0.1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 469524a1516a751b365af2de4d5712e3818c7dc250b19ea6f4672c88dd0c22ed |
|
MD5 | 2f33e8bb0400475f698e371e844cf97a |
|
BLAKE2b-256 | 5b1e4fbdbf71650c67fab5afd003a66afa522029dddf925e02b8e21f965d38e9 |