django-best-templatetags¶
Best tags and filters for Django templates
Installation¶
Install with pip:
pip install best_templatetags
Then declare the app in your settings.py
INSTALLED_APPS = [
...
'best_templatetags',
]
To use the filters, add in your template:
{% load best_filters %}
To use the tags, add in your template:
{% load best_tags %}
Filters¶
age |
give the age in year |
basename |
give the basename of the path |
dirname |
give the directory name of the path |
divide |
Divide by a value |
get_key |
Give access to a dict value with a key contained in a var |
listsort |
Sort a list or a list of lists/tuples |
listsortreversed |
Sort a list or a list of lists/tuples in reversed order |
multiply |
Multiply by a value |
replace |
Replace a substring |
resub |
regex substitute a substring |
sanitizetags |
Remove all tags that is not in the allowed list |
truncat |
truncate the string at the specified pattern |
Tags¶
extend_url |
Update url parameters |
hash |
Return a hexadecimal md5 digest of a string |
render_template |
Render a string as it was a Django template |
update_url |
Update url parameters |