Skip to main content

django-appconf

Code Coverage Build Status

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 AcmeAppConf(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:

ACME_SETTING_1 = "uno"

Since django-appconf completes Django’s global settings with its default values (like “one” above), the standard python manage.py diffsettings will show these defaults automatically.

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'

If you ship an AppConf class with your reusable Django app, it’s recommended to put it in a conf.py file of your app package and import django.conf.settings in it, too:

from django.conf import settings
from appconf import AppConf

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

In the other files of your app you can easily make sure the settings are correctly loaded if you import Django’s settings object from that module, e.g. in your app’s views.py:

from django.http import HttpResponse
from myapp.conf import settings

def index(request):
    text = 'Setting 1 is: %s' % settings.MYAPP_SETTING_1
    return HttpResponse(text)

Metadata

Release files for django-appconf 1.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-appconf 1.0.5
File Size Uploaded Provenance Actions
django-appconf-1.0.5.tar.gz 15.9 kB Without provenance Details for django-appconf-1.0.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-appconf 1.0.5
File Interpreter ABI Platform Actions
django_appconf-1.0.5-py3-none-any.whl Python 3 none any Details for django_appconf-1.0.5-py3-none-any.whl

Total release size: 22.3 kB

Release files / django-appconf-1.0.5.tar.gz

Download URL django-appconf-1.0.5.tar.gz
Size 15.9 kB
Tags Source
SHA-256 checksum
How to use checksums
be3db0be6c81fa84742000b89a81c016d70ae66a7ccb620cdef592b1f1a6aaa4
BLAKE2b-256 checksum
How to use checksums
d6dcab95f120aa249f215b1a7925a9062393c039481e1df77b4455e021ae6f67
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.6

Release files / django_appconf-1.0.5-py3-none-any.whl

Download URL django_appconf-1.0.5-py3-none-any.whl
Size 6.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ae9f864ee1958c815a965ed63b3fba4874eec13de10236ba063a788f9a17389d
BLAKE2b-256 checksum
How to use checksums
489578c279b7861efd8b0282e9373d40ec7247664bf1246a6cdc9e59d281ceb0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.6

Security for django-appconf 1.0.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page