#1 by E_P
Hey everyone,
I know Django isn’t part of oTree anymore, but is there any doc on what formatting options you can use in templates? I was trying something like {{ t.lottery_high|floatformat:2 }}, but I guess I’ll just format it in Python with .2f instead.
Any tips would be awesome, thanks!
EP
#2
by
BonnEconLab
There are three filters: {{ ... | to0 }} for rounding to an integer, {{ ... | to1 }} for rounding to 1 decimal place, and {{ ... | to2 }} for rounding to 2 decimal places. See https://otree.readthedocs.io/en/latest/templates.html#miscellaneous.
#3 by E_P
Thanks for the info! Do you know if there’s a place where we can find all the available option possibilities?
#4
by
Chris_oTree
it's only to0, to1, to2. In oTree 6.0 beta there is to3 and to4, and THOUSAND_SEPARATOR. See here: https://otree.readthedocs.io/en/latest/templates.html#number-formatting