Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/funkybob/django-classy-settings
Minimalist approach to class-based settings for Django
https://github.com/funkybob/django-classy-settings
Last synced: 3 months ago
JSON representation
Minimalist approach to class-based settings for Django
- Host: GitHub
- URL: https://github.com/funkybob/django-classy-settings
- Owner: funkybob
- License: bsd-2-clause
- Created: 2014-07-24T03:45:30.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2024-05-13T03:05:55.000Z (6 months ago)
- Last Synced: 2024-07-20T22:27:28.609Z (4 months ago)
- Language: Python
- Size: 172 KB
- Stars: 34
- Watchers: 3
- Forks: 13
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-django - django-classy-settings - Class based settings to keep your environments in order, with easy access to typed environment variables. (Third-Party Packages / Configuration)
README
django-classy-settings
======================Minimalist approach to class-based settings for Django
https://django-classy-settings.readthedocs.io/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