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(prefix='DJANGO_')
class Settings(BaseSettings):
DEBUG = denv.bool(True) # Controlled by DJANGO_DEBUG
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__ = 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 Distribution
Built Distribution
Close
Hashes for django-classy-settings-3.0.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 37db9f8bfacca2e59997cc2c7c374507b89cadecaea05204c50a1d6e86d04afa |
|
MD5 | 8aac3d929c57bdb1e16d6f6a8331de4b |
|
BLAKE2b-256 | 152dcf57a75fdcaaad79e0eadaa6f6adc4501691839352c3804c6ad9c2a3bcec |
Close
Hashes for django_classy_settings-3.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1ee2c9c9561cf409b97bde4ccc0a174b1b0195972742b1b32b6ecd3d91985e03 |
|
MD5 | 3fb669ff4511e308e28e47c88840455f |
|
BLAKE2b-256 | 366514f0d80fffc478a223442f53e71a9cc32e1c3582b4552b5d44cc35beebb3 |