mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
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
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user