floatformat Filter

Number Most Useful

Argument: n (Optional) – the number of decimal places to round to.

Documentation

The floatformat filter takes an n argument for the number of decimal places to round to. Without that argument, it will round to one decimal place unless the decimal value is 0, in which case it will just output the integer.

filter 1000.0 1000.11 3.14159
{{ i|floatformat }} 1000 1000.1 3.1
{{ i|floatformat:2 }} 1000.00 1000.11 3.14
{{ i|floatformat:0 }} 1000 1000 3

Did we get something wrong? Is there a use case for the floatformat filter that we should add? Please let us know.

Send Feedback

Official Documentation
This page last updated on Oct. 30, 2022, 1:21 p.m. EST