Split before decimal in django -
i have variable fetches data database
{{i.rewardpoints}}
and values returns such 1.799 or 12 db has multiple values contains decimals , without decimals
but need show values without decimals
how can this
to round nearest integer:
{{ i.rewardpoints|floatformat:"0" }}
to integer part:
{{ i.rewardpoints|stringformat:"d" }}
in [19]: tpl = template('{{ x|stringformat:"d" }} {{ x|floatformat:"0" }}') in [20]: tpl.render(context({'x': 1.1})) out[20]: u'1 1' in [21]: tpl.render(context({'x': 1.9})) out[21]: u'1 2'
Comments
Post a Comment