Skip to main content

Per app constance settings

Project description

Constance register - constance for third-party packages

Features:

  • Easily add settings to global constance config from third-party packages or project applications

How to use it

Install constance and constance register

>>> pip install django-constance django-constance-register

Add constance to INSTALLED_APPS

INSTALLED_APPS = (
    ...
    'constance',
    'constance.backends.database',
    'constance_register',
    ...

At the end of settings file add

from constance_register.conf import conf

# Path to your files with configs. 
# NOTE: Files are loaded before apps are ready
CONSTANCE_REGISTRY = [
    'library.apps.shelf',
    'library.apps.staff'
]
# Load settings
conf.load()

# Add third-party settings to global settings
CONSTANCE_CONFIG = {
     'THE_ANSWER': (42, 'Answer to the Ultimate Question of Life, '
                       'The Universe, and Everything'),
    **conf.settings()
}
# Same with fieldsets
CONSTANCE_CONFIG_FIELDSETS = {
    **conf.fieldsets()
}

Add your settings to config.py file. Config file example.

# library.apps.staff.config.py
from datetime import date

app_name = 'staff'

CONFIG = {
    'DATE_ESTABLISHED': (date(1972, 11, 30), "the shop's first opening"),
    'MY_SELECT_KEY': ('yes', 'select yes or no', 'yes_no_null_select'),
    'MULTILINE': ('Line one\nLine two', 'multiline string'),
}

FIELDSET = {
    'General Options': {
        'fields': ('DATE_ESTABLISHED', 'MY_SELECT_KEY'),
        'collapse': True
    },
    'Theme Options': ('MULTILINE',),
}

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-constance-register-0.2.0.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_constance_register-0.2.0-py3-none-any.whl (18.3 kB view details)

Uploaded Python 3

File details

Details for the file django-constance-register-0.2.0.tar.gz.

File metadata

File hashes

Hashes for django-constance-register-0.2.0.tar.gz
Algorithm Hash digest
SHA256 0409b8cea288e00534432c6d1b2ed520157e625acb0c6725611e9e4644297e7c
MD5 7e4264f31439c984733ada3dd0eb4ce3
BLAKE2b-256 0e1a01e2de88ca3c30c280c07aed52e7ec3b6fcf898d10d956f7169a81386873

See more details on using hashes here.

File details

Details for the file django_constance_register-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_constance_register-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0dcfaa66c830bb74b595284acfdb7200c7cae506f68730a6983ed7fadb93f46f
MD5 014f0ba4749fa995eb093bcf1f6a0f56
BLAKE2b-256 0da3a790e7fb9a05e62bf5d559b43409f2a221a01243f952d24f7798ee34992a

See more details on using hashes here.

Supported by

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