Using python string formatting in a django template -
is there easy way use python string formatting within django template? is, i'd able in template
{{ variable|%.3f }} i know in case, 1 can use
{{ variable|floatformat:3 }} but i'd able generically use python string format on django variable. in system it's inconvenient have deal 2 different ways format output (python vs django), i'd standardize. write custom template tag like
{% pyformat variable format="%.3f" %} or maybe custom template filter like
{{ variable|pyformat:"%.3f" }} do either of these exist? customer filter work string passed in that?
{{ variable|stringformat:".3f" }} source: http://docs.djangoproject.com/en/dev/ref/templates/builtins/#stringformat
Comments
Post a Comment