Skip to main content

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/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


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

django_classy_settings-3.0.7-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file django_classy_settings-3.0.7-py3-none-any.whl.

File metadata

File hashes

Hashes for django_classy_settings-3.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 c2021f1bcebb9770047867eba003ae8ce280f46cf6a27a75cff8f8635ad64b85
MD5 2e5efd5a7bbab224fc591c1c8cc039ec
BLAKE2b-256 52cae2350391f5c59bf976a1dfd6ddd80ee5a6d956abe09a3c31ac9b27cafaf5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page