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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_classy_settings-3.0.3.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

django_classy_settings-3.0.3-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file django_classy_settings-3.0.3.tar.gz.

File metadata

File hashes

Hashes for django_classy_settings-3.0.3.tar.gz
Algorithm Hash digest
SHA256 3d43c0ca474efec9269b6a506b07c69a29f763a094228fbec27a5a0abe2c27a4
MD5 87673fce7e738508f92ee7308bc06f7d
BLAKE2b-256 b42088cdd3cfd5a91c55f4513f8cad45ac57b42ae3ed02bc7fdab8e7434e364c

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for django_classy_settings-3.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7a278ffb11ad25bc347a900ba6b0f290e1c278d3f7313505e42f9a77ac78bc78
MD5 9a500ac39efc4f12771947632e6a7d6c
BLAKE2b-256 098e5e3b88dec517d2c906ce8cfec694b6f79a40ed32c69ddbb3f00aa176575e

See more details on using hashes here.

Provenance

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