Login

Tag "string-formatting"

Snippet List

Simple template tag to do |stringformat filter with format from a variable

Formats a django variable using a python string formatting as specified in another template variable. Similar to |stringformat. Takes two arguments: the django template variable with the item to be formatted and the django template variable containing the format string. {% pyformat number formatstringvar %} Place this file in `appname/templatetags/pyformat.py` and you're good.

  • template-tag
  • string-formatting
Read More

2 snippets posted so far.