Last active
August 29, 2015 14:10
-
-
Save balazs-endresz/fda4f55c6f47e57b40f7 to your computer and use it in GitHub Desktop.
Do both rounding and float formatting in django templates
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{ value|floatformat|floatformat }} | |
or: | |
{{ value|floatformat:-1|floatformat:-1 }} | |
1.0 -> 1 | |
1.01 -> 1 # this would be 1.0 with one floatformat filter | |
1.10 -> 1.1 | |
1.123 -> 1.1 | |
1.9 -> 1.9 | |
https://docs.djangoproject.com/en/dev/ref/templates/builtins/#floatformat |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment