Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #19241 -- Improved floatformat docs

Demonstrate how to round to integers using floatformat templatetag
  • Loading branch information...
commit dbe984c397d6c1e49167dd8fbfb655dd17a14572 1 parent d35b95c
Daniel Greenfeld authored November 04, 2012 ptone committed November 04, 2012

Showing 1 changed file with 11 additions and 0 deletions. Show diff stats Hide diff stats

  1. 11  docs/ref/templates/builtins.txt
11  docs/ref/templates/builtins.txt
@@ -1505,6 +1505,17 @@ that many decimal places. For example:
1505 1505
 ``34.26000``  ``{{ value|floatformat:3 }}``  ``34.260``
1506 1506
 ============  =============================  ==========
1507 1507
 
  1508
+Particularly useful is passing 0 (zero) as the argument which will round the
  1509
+float to the nearest integer.
  1510
+
  1511
+============  ================================  ==========
  1512
+``value``     Template                          Output
  1513
+============  ================================  ==========
  1514
+``34.23234``  ``{{ value|floatformat:"0" }}``   ``34``
  1515
+``34.00000``  ``{{ value|floatformat:"0" }}``   ``34``
  1516
+``39.56000``  ``{{ value|floatformat:"0" }}``   ``40``
  1517
+============  ================================  ==========
  1518
+
1508 1519
 If the argument passed to ``floatformat`` is negative, it will round a number
1509 1520
 to that many decimal places -- but only if there's a decimal part to be
1510 1521
 displayed. For example:

0 notes on commit dbe984c

Please sign in to comment.
Something went wrong with that request. Please try again.