Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #19241 -- Improved floatformat docs

Demonstrate how to round to integers using floatformat templatetag
  • Loading branch information...
commit a70492e6b532905c921678f35b5c60b22387f1c6 1 parent 4d766b3
@pydanny pydanny authored ptone committed
Showing with 11 additions and 0 deletions.
  1. +11 −0 docs/ref/templates/builtins.txt
View
11 docs/ref/templates/builtins.txt
@@ -1505,6 +1505,17 @@ that many decimal places. For example:
``34.26000`` ``{{ value|floatformat:3 }}`` ``34.260``
============ ============================= ==========
+Particularly useful is passing 0 (zero) as the argument which will round the
+float to the nearest integer.
+
+============ ================================ ==========
+``value`` Template Output
+============ ================================ ==========
+``34.23234`` ``{{ value|floatformat:"0" }}`` ``34``
+``34.00000`` ``{{ value|floatformat:"0" }}`` ``34``
+``39.56000`` ``{{ value|floatformat:"0" }}`` ``40``
+============ ================================ ==========
+
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. For example:
Please sign in to comment.
Something went wrong with that request. Please try again.