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

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -