Adds ability to define Django settings with classes/functions and navigate each of them easily
Project description
Adds ability to define Django settings with classes.
As many text editors and IDEs indexes code symbols, with such approach you can easily navigate to any group and any line of your settings file.
Settings class
Exports defined variables into module’s scope:
from classsettings import Settings
class Administration(Settings):
def ADMINS(self): return (
('Your Name', 'your_email@example.com'),
)
def DEBUG(self): return False
def TEMPLATE_DEBUG(self): return self.DEBUG()
Will result in
ADMINS = (
('Your Name', 'your_email@example.com'),
)
DEBUG = False
TEMPLATE_DEBUG = False
Config class
Injects dictionary if variables into module’s scope:
from classsettings import Config
class REST_FRAMEWORK(Config):
def DEFAULT_FILTER_BACKENDS(self): return (
'rest_framework.filters.DjangoFilterBackend',
)
Will result in
REST_FRAMEWORK = {
'DEFAULT_FILTER_BACKENDS': (
'rest_framework.filter.DjangoFilterBackend',
)
}
Decorators
Some decorators may be found usefull:
from classsettings import Settings, from_env
class MySettingsGroup(Settings):
# Will look for `EMAIL_HOST` key in `os.environ`
# and use `smtp.gmail.com` if such key was not found
@from_env
def EMAIL_HOST(self): return 'smtp.gmail.com'
# Will raise Django's `ImproperlyConfigured` exception
# if such key was not found
@from_env
def SECRET_KEY(self): pass
# Will look for specified key
@from_env(key='CUSTOM_ENV_VAR_NAME')
def VAR_NAME(self): 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
Close
Hashes for django-classsettings-1.0.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | b116ed498723c0f871e7d0bd21c9386ad6e317849c5b3b4c9a3aec1aa2f4243c |
|
MD5 | 0c467e73079cb9e8a7d55246f15f2c7a |
|
BLAKE2b-256 | be9e53d8ed00247c39bef6f4372df73ef1a0e410298709de3c280ae172b6ad82 |