Skip to main content

Define constants in your settings, and make them available in your templates.

Project description


Define constants in your settings file, that are then made available in your templates.


From the command line:

pip install django-tagconstants

Add tagconstants to your installed apps:


Create a TAG_CONSTANTS dictionary in your file:



For security purposes, tagconstants is designed so that you create a whitelist of variables to make available in your templates. For more information see the Design and Security section.

To use a constant in your templates, first add the constant to your TAG_CONSTANTS setting:


Then in your templates, you can recall these constants with the {% constant ... %} template tag:

{% load tagconstants %}

{% constant "CONSTANT" %}
    {# renders to 'SOME STRING' #}

{% constant "CONSTANT" as "variable_name" %}
    {# loads the template variable variable_name="SOME STRING" #}
    {# into the template context #}


Pull, fork, do whatever you’d like with the code.

Project details

Release history Release notifications

This version
History Node


Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date (9.4 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page