diff options
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/ref/templates/builtins.txt | 21 |
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 |
