django-tagconstants
Define constants in your settings file, that are then made available in your templates.
Installation
From the command line:
pip install django-tagconstants
Add tagconstants to your installed apps:
INSTALLED_APPS = (
...
'tagconstants',
...
)
Create a TAG_CONSTANTS dictionary in your settings.py file:
TAG_CONSTANTS = {}
Usage
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:
TAG_CONSTANTS = {
'CONSTANT': 'SOME STRING',
}
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 #}
Contributing
Pull, fork, do whatever you’d like with the code.
Release files for django-tagconstants 0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| django-tagconstants-0.1.zip | 9.4 kB | Details |
Release files / django-tagconstants-0.1.zip
| Download URL | django-tagconstants-0.1.zip |
|---|---|
| Size | 9.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0e2ae4a2e00183cce86f3d95f8396e6e5239aefe280687e07dd7238e2a24f93e
|
|
BLAKE2b-256 checksum How to use checksums |
1af9ecf04276443794a0b9f175e353d2ab3ac8eb50458bded5f33a3367511435
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |