Skip to main content

This Django app allows you to export certain settings to your templates.

Project description

PyPi Build Status of the master branch Coverage

Often it is needed to make some of your Django project’s settings accessible from within templates. This app provides a simple mechanism for doing just that.


  • Explicit is better than implicit: Only explicitly listed settings keys are exported to templates.
  • Errors should never pass silently: Accessing an undefined or unexported setting key from a template results in an exception.

Tested on Python 2.7+, Django 1.5+.


$ pip install django-settings-export

Add 'django_settings_export.settings_export' to TEMPLATE_CONTEXT_PROCESSORS in your

    # [...]


All settings that should be made accessible from templates need to be explicitly listed in settings.SETTINGS_EXPORT:


DEBUG = True
GA_ID = 'UA-00000-0'


Now you can access those exported settings from your templates via settings.<KEY>:

{% if not settings.DEBUG %}
    <script>ga('create', '{{ settings.GA_ID }}', 'auto');</script>
{% endif %}


  • Listing an undefined setting key in SETTINGS_EXPORT results in an UndefinedSettingError.
  • Accessing a unexported setting key on the settings object in a template results in an UnexportedSettingError.

See also the bundled demo app.


$ cd demo

# Run demo
$ python runserver

# Run tests on current Python
$ python test

# Run tests on all Pythons
$ tox


BSD. See LICENCE for more details.

Project details

Download files

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

Files for django-settings-export, version 1.0.3
Filename, size File type Python version Upload date Hashes
Filename, size django-settings-export-1.0.3.tar.gz (3.5 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page