I favor raising an exception in this case, because values in this context are not coerced to strings (unlike the case in {{ }} references).
IMO, and in order to protect the writers of all 3rd-party filters, the only way to solve this without raising an exception is to resolve the whole filter expression to string_if_invalid, rather than just the missing var. Shai On Thursday 01 June 2017 03:10:39 Jon Dufresne wrote: > Just my opinion, but I think raising an exception is more helpful to > developers and will result in fewer unnoticed bugs. > > More generally, I know the template engine has a history of silently > converting unknown variables to string_if_invalid but this is more harmful > than helpful in my experience. It continues to be a source of hard to catch > bugs on the projects I work on. So I'd prefer we avoid introducing more of > this pattern if possible. > > On Wed, May 31, 2017 at 8:03 AM, Tim Graham <timogra...@gmail.com> wrote: > > Should nonexistent template filter arguments raise an exception? Current > > behavior: > > > > {{ value|filter:nonexistent_template_var}} > > > > raises VariableDoesNotExist for nonexistent_template_var. > > > > I guess the proposal would be to make nonexistent_tempatle_var resolve to > > string_if_invalid. As for me, I think the current behavior is less error > > prone. > > > > Related tickets: > > > > https://code.djangoproject.com/ticket/13167 > > This was first closed incorrectly as "fixed" by Jacob (actually a > > different issue was fixed), then amended as wontfix by Karen with the > > note, "I'm fine with wontfixing that, though it does rather seem to go > > against "template errors don't raise exceptions" philosophy." > > > > https://code.djangoproject.com/ticket/28172 > > A follow up ticket requesting the same thing as #13167. > > > > -- > > You received this message because you are subscribed to the Google Groups > > "Django developers (Contributions to Django itself)" group. > > To unsubscribe from this group and stop receiving emails from it, send an > > email to django-developers+unsubscr...@googlegroups.com. > > To post to this group, send email to django-developers@googlegroups.com. > > Visit this group at https://groups.google.com/group/django-developers. > > To view this discussion on the web visit https://groups.google.com/d/ > > msgid/django-developers/02727bd0-5a67-4cf9-9c3f- > > b0a0a7ea0a3a%40googlegroups.com > > <https://groups.google.com/d/msgid/django-developers/02727bd0-5a67-4cf9-9 > > c3f-b0a0a7ea0a3a%40googlegroups.com?utm_medium=email&utm_source=footer> . > > For more options, visit https://groups.google.com/d/optout.