- Author:
- pryankster
- Posted:
- April 6, 2007
- Language:
- Python
- Version:
- .96
- Score:
- 11 (after 11 ratings)
I found myself putting {%load ... %}
in every template that I was writing, so DRY .. I created an app called 'globaltags' and in its __init__.py
, I just pre-load the tags that I use frequently.
The pyif and expr tags are excellent tags, and I highly recommend them for getting the most out of django's template language.
The dbinfo snippet is something that I came up with to easily output SQL debugging information.
1 2 3 4 5 6 | # <mysite>/globaltags/__init__.py
from django.template import add_to_builtins
add_to_builtins('globaltags.pyif')
add_to_builtins('globaltags.expr')
add_to_builtins('globaltags.dbinfo')
|
More like this
- Template tag - list punctuation for a list of items by shapiromatron 11 months, 2 weeks ago
- JSONRequestMiddleware adds a .json() method to your HttpRequests by cdcarter 11 months, 3 weeks ago
- Serializer factory with Django Rest Framework by julio 1 year, 6 months ago
- Image compression before saving the new model / work with JPG, PNG by Schleidens 1 year, 7 months ago
- Help text hyperlinks by sa2812 1 year, 7 months ago
Comments
Took me a second to realize I still had to add
'<mysite>.globaltags'
toINSTALLED_APPS
, then it worked like a charm! Thanks.#
Please login first before commenting.