print empty value
--
Ticket URL: <https://code.djangoproject.com/ticket/25118>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
* type: Bug => Cleanup/optimization
* stage: Unreviewed => Accepted
Comment:
The issue is that the `add` filter doesn't support mixed types (string and
integer in this case). It might be reasonable to add such support.
--
Ticket URL: <https://code.djangoproject.com/ticket/25118#comment:1>
* cc: konrad.swiat@… (added)
* owner: nobody => kswiat
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/25118#comment:2>
Comment (by kswiat):
https://docs.djangoproject.com/en/1.8/ref/templates/builtins/#add
{{{
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.
}}}
References: #11687, #16676
The question is, how the `add` tag should behave. If adding fails, do we
expect the result to be concatenated string? Maybe we need separate tag to
do that?
--
Ticket URL: <https://code.djangoproject.com/ticket/25118#comment:3>
* status: assigned => closed
* resolution: => wontfix
Comment:
I guess it's a "won't fix" based on the discussion in #16676 then. I don't
think Django needs to add a new filter for this case.
--
Ticket URL: <https://code.djangoproject.com/ticket/25118#comment:4>
Comment (by chadhs):
This seems to not be a bug. I did some simple tests to confirm the
behavior is consistent with the documentation.
The add filter correctly concats strings.
It also correctly coerces a string to an int adding allowing it to be
added to a subsequent int.
Two ints are also correctly added.
Lastly a string like my name fails to be coerced to an int and when added
to an int returns an empty value.
Once again, this is consistent with the docs. Thanks.
--
Ticket URL: <https://code.djangoproject.com/ticket/25118#comment:5>