Django – remove trailing zeroes for a Decimal in a template
The solution is to use the normalize()
method:
{{ balance.bitcoins.normalize }}
Try {{ balance.bitcoins|floatformat:"-3" }}
.
https://docs.djangoproject.com/en/2.0/ref/templates/builtins/#floatformat:
If the argument passed to floatformat is negative, it will round a number to that many decimal places – but only if there’s a decimal part to be displayed.