Simple class-based settings for Django
Project description
django-classy-settings
Minimalist approach to class-based settings for Django
https://django-classy-settings.readthedocs.io/en/latest/
Quick Start
In your settings.py
from cbs import BaseSettings, env
...
# For env settings with a DJANGO_ prefix
denv = env['DJANGO_']
class Settings(BaseSettings):
DEBUG = denv.bool(True) # Controlled by DJANGO_DEBUG env var
DEFAULT_DATABASE = denv.dburl('sqlite://db.sqlite')
def DATABASES(self):
return {
'default': self.DEFAULT_DATABASE,
}
class ProdSettings(Settings):
DEBUG = False
@env
def STATIC_ROOT(self):
raise ValueError("Must set STATIC_ROOT!")
__getattr__, __dir__ = BaseSettings.use()
Switch between Settings
and ProdSettings
using the DJANGO_MODE
env var:
# Run default Settings
$ ./manage.py test
# Run ProdSettings
$ DJANGO_MODE=prod ./manage.py test
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 Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for django_classy_settings-3.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 72e2da76aaf09f75b78c47930d0dbb317e6d437da9c00196faedc81b52e2784b |
|
MD5 | 4880fec8ffde01f8f781b9668b3640eb |
|
BLAKE2b-256 | 3413dacf6bf0ece2d05a5741893e675188ab2044b62d56c6806156376605afa4 |