summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorDaniel Greenfeld <pydanny@gmail.com>2012-11-04 16:35:40 -0800
committerPreston Holmes <preston@ptone.com>2012-11-04 17:45:30 -0800
commitdbe984c397d6c1e49167dd8fbfb655dd17a14572 (patch)
treed3e4db137f61e91eca4c732e61d1a7ce1af15b8d /docs
parentd35b95c2f45bc5bc91deab12e503b04126fe70d7 (diff)
Fixed #19241 -- Improved floatformat docs
Demonstrate how to round to integers using floatformat templatetag
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/templates/builtins.txt11
1 files changed, 11 insertions, 0 deletions
diff --git a/docs/ref/templates/builtins.txt b/docs/ref/templates/builtins.txt
index 4aa1a990cd..c7fab8c53d 100644
--- a/docs/ref/templates/builtins.txt
+++ b/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: