Skip to content

Django Dynamic Setting is a Django app, designed to help you manage your project settings, storage settings in database, provided admin UI to manage there settings.

License

Notifications You must be signed in to change notification settings

cuongnb14/django-dynamic-setting

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Django Dynamic Setting

Django Dynamic Setting is a Django app, designed to help you manage your project settings, storage settings in database, provided admin UI to manage there settings.

Setup

pip install git+https://github.com/cuongnb14/django-dynamic-setting@master#egg=django-dynamic-setting

Add to install app

INSTALLED_APPS = [
    ...
    "dynamic_setting",
    ...
]

Run migrate

python3 manage.py migrate

Define setting in your code

# your_app/setting.py
from dynamic_setting.base.fields import IntegerSettingField, BooleanSettingField, CharSettingField
from dynamic_setting.base.settings import Settings


class BotSettings(Settings):

    sell_enable = BooleanSettingField(default=1, description='enable sell action')
    title = CharSettingField(default="hello", is_public=True)
    version = CharSettingField(default=1, min_value=0, max_value=10, is_public=True)

    class Meta:
        name = 'bot'

# your_app/apps.py
from django.apps import AppConfig
from dynamic_setting.settings_registry import settings_registry

from .setting import BotSettings


class BotConfig(AppConfig):
    name = "cg_bot.bot"
    verbose_name = "Bots"

    def ready(self):
        settings_registry.register(BotSettings)

Init setting

python3 manage.py init_dynamic_setting

Use setting

setting = BotSettings()
print(setting.title)

About

Django Dynamic Setting is a Django app, designed to help you manage your project settings, storage settings in database, provided admin UI to manage there settings.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages