summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorJacob Kaplan-Moss <jacob@jacobian.org>2010-02-22 23:34:33 +0000
committerJacob Kaplan-Moss <jacob@jacobian.org>2010-02-22 23:34:33 +0000
commit49d6a82261feda6ee1bf23bb17184e932e232172 (patch)
treedbdf8122115f57461ed8e306f68160b48fa46479 /docs
parenteb0751a4c0b2d5e248ff3babc37a4764b102e25a (diff)
Fixed #11687: the `add` filter is now less failsome when faced with things that can't be coerced to integers.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12497 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/templates/builtins.txt21
1 files changed, 21 insertions, 0 deletions
diff --git a/docs/ref/templates/builtins.txt b/docs/ref/templates/builtins.txt
index b9fa99bf6f..aabacc5650 100644
--- a/docs/ref/templates/builtins.txt
+++ b/docs/ref/templates/builtins.txt
@@ -1010,6 +1010,27 @@ For example::
If ``value`` is ``4``, then the output will be ``6``.
+.. versionchanged:: 1.2
+ The following behavior didn't exist in previous Django versions.
+
+This filter will first try to coerce both values to integers. If this fails,
+it'll attempt to add the values together anyway. This will work on some data
+types (strings, list, etc.) and fail on others. If it fails, the result will
+be an empty string.
+
+For example, if we have::
+
+ {{ first|add:second }}
+
+and ``first`` is ``[1, 2, 3]`` and ``second`` is ``[4, 5, 6]``, then the
+output will be ``[1, 2, 3, 4, 5, 6]``.
+
+.. warning::
+
+ Keep in mind that strings that can both be coerced to integers will be,
+ and thus will be will be *summed*, not concatenated, as in the first
+ example above.
+
.. templatefilter:: addslashes
addslashes