Django and floatformat tag

Posted by Hellnar on Stack Overflow See other posts from Stack Overflow or by Hellnar
Published on 2010-04-06T09:56:26Z Indexed on 2010/04/06 10:23 UTC
Read the original article Hit count: 597

Hello, I want to modify / change the way the floatformat works.

By default it changes the input decimal as such:

{{ 1.00|floatformat }} -> 1
{{ 1.50|floatformat }} -> 1.5
{{ 1.53|floatformat }} -> 1.53

I want to change this abit as such: If there is a floating part, it should keep the first 2 floating digits. If no floating (which means .00) it should simply cut out the floating part. IE:

{{ 1.00|floatformat }} -> 1
{{ 1.50|floatformat }} -> 1.50
{{ 1.53|floatformat }} -> 1.53

© Stack Overflow or respective owner

Related posts about django

Related posts about django-templates