Skip to main content

A helper class for handling configuration defaults of packaged apps gracefully.

Project description

A helper class for handling configuration defaults of packaged Django apps gracefully.

Overview

Say you have an app called myapp with a few defaults, which you want to refer to in the app’s code without repeating yourself all the time. appconf provides a simple class to implement those defaults. Simply add something like the following code somewhere in your app files:

from appconf import AppConf

class MyAppConf(AppConf):
    SETTING_1 = "one"
    SETTING_2 = (
        "two",
    )

The settings are initialized with the capitalized app label of where the setting is located at. E.g. if your models.py with the AppConf class is in the myapp package, the prefix of the settings will be MYAPP.

You can override the default prefix by specifying a prefix attribute of an inner Meta class:

from appconf import AppConf

class MyAppConf(AppConf):
    SETTING_1 = "one"
    SETTING_2 = (
        "two",
    )

class Meta:
    prefix = 'acme'

The MyAppConf class will automatically look at Django’s global settings to determine if you’ve overridden it. For example, adding this to your site’s settings.py would override SETTING_1 of the above MyAppConf:

MYAPP_SETTING_1 = "uno"

In case you want to use a different settings object instead of the default 'django.conf.settings', set the holder attribute of the inner Meta class to a dotted import path:

from appconf import AppConf

class MyAppConf(AppConf):
    SETTING_1 = "one"
    SETTING_2 = (
        "two",
    )

class Meta:
    prefix = 'acme'
    holder = 'acme.conf.settings'

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-appconf-0.4.tar.gz (4.7 kB view details)

Uploaded Source

File details

Details for the file django-appconf-0.4.tar.gz.

File metadata

File hashes

Hashes for django-appconf-0.4.tar.gz
Algorithm Hash digest
SHA256 162794402510e6adb091369d792ddb7e7fb7b9ce809ec5293647cefa499658a1
MD5 8fb356b81a06dfa9cede1b1c79d62fd1
BLAKE2b-256 1b4782baa01121fbf6bb225b459bdfb006ad1ab68ae2443c4208e2a7761b2add

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