skip to navigation
skip to content

django-constance-trbs 0.5.1

Django live settings with pluggable backends, including Redis.

Latest Version: 0.7.9


This is a fork of the original django-constance project which can be found at:

Main reason for the fork is to have django-constance pip installable with Django 1.4+ compatibility fixes.

Hopefully we can have this fork merged back into the official repository as soon as possible.


  • Easily migrate your static settings to dynamic settings.
  • Admin interface to edit the dynamic settings.


Install from PyPI:

pip install django-constance-trbs

Or install the git development version using pip:

pip install -e git+git://


Modify your Add 'constance' to your INSTALLED_APPS, and move each key you want to turn dynamic into the CONSTANCE_CONFIG section, like this:


        'default': 42,
        'help_text': 'the answer to everything'

Here, 42 is the default value for the key MY_SETTINGS_KEY if it is not found in the backend. The help text will be shown in the admin.

See the Backends section how to setup the backend.


Constance ships with a bunch of backends that are used to store the configuration values. By default it uses the Redis backend. To override the default please set the CONSTANCE_BACKEND setting to the appropriate dotted path.

Redis (default)

CONSTANCE_BACKEND = 'constance.backends.redisd.RedisBackend'

The is the default backend and has a couple of options:


    A dictionary of parameters to pass to the to Redis client, e.g.:

        'host': 'localhost',
        'port': 6379,
        'db': 0,

    An (optional) dotted import path to a connection to use, e.g.:

    CONSTANCE_REDIS_CONNECTION_CLASS = 'myproject.myapp.mockup.Connection'

    The (optional) prefix to be used for the key when storing in the Redis database. Defaults to 'constance:'. E.g.:

    CONSTANCE_REDIS_PREFIX = 'constance:myproject:'


CONSTANCE_BACKEND = constance.backends.database.DatabaseBackend

If you want to use this backend you also need to add the databse backend to your INSTALLED_APPS setting to make sure the data model is correctly created:

    # other apps

It also uses django-picklefield to store the values in the database, so you need to install this library, too. E.g.:

pip install django-picklefield

The database backend has the ability to automatically cache the config values and clear them when saving. You need to set the following setting to enable this feature:



This won’t work with a cache backend that doesn’t support cross-process caching, because correct cache invalidation can’t be guaranteed.


Constance can be used from your Python code and from your Django templates.

  • Python

    Accessing the config variables is as easy as importing the config object and accessing the variables with attribute lookups:

    from constance import config
    # ...
    if config.MY_SETTINGS_KEY == 42:
  • Django templates

    To access the config object from your template, you can either pass the object to the template context:

    from django.shortcuts import render_to_response
    from constance import config
    def myview(request):
        return render_to_response('my_template.html', {'config': config})

    Or you can use the included config context processor.:

        # ...

    This will add the config instance to the context of any template rendered with a RequestContext.

    Then, in your template you can refer to the config values just as any other variable, e.g.:

    <h1>Welcome on {% config.SITE_NAME %}</h1>
    {% if config.BETA_LAUNCHED %}
        Woohoo! Head over <a href="/sekrit/">here</a> to use the beta.
    {% else %}
        Sadly we haven't launched yet, click <a href="/newsletter/">here</a>
        to signup for our newletter.
    {% endif %}


Fire up your admin and you should see a new app called Constance with MY_SETTINGS_KEY in the Config pseudo model.


The standard edit screen.

The virtual application Constance among your regular applications.

File Type Py Version Uploaded on Size
django-constance-trbs-0.5.1.tar.gz (md5, pgp) Source 2013-01-23 13KB
  • Downloads (All Versions):
  • 25 downloads in the last day
  • 244 downloads in the last week
  • 1578 downloads in the last month