{{{
#!python
from django.template import Context, Template
Template('{{ foo|default:notreal }}').render(Context({'foo': ''}))
}}}
still raises `VariableDoesNotExist` exception, which is completely
unexpected from templates, as noted in closing comment
ticket:13167#comment:20. I took me more than an hour before I found out
how did it make the server error I investigated.
I know the original ticket was closed as wontfix, but I understood it was
due to the effect the proposed change would have on `if` tag. But there's
another way - capture the exception in `VariableNode` the similar way
`UnicodeDecodeError` is silenced. If I understood the code correctly, that
would solve the problem for all template filters, but left template tags
intact.
--
Ticket URL: <https://code.djangoproject.com/ticket/28172>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* stage: Unreviewed => Someday/Maybe
Comment:
I understand the "template errors don't raise exceptions" philosophy,
however, I think changing the current behavior would be more error prone
(e.g. typos in variable names go more easily undetected). I've started a
[https://groups.google.com/d/topic/django-
developers/VPzVbQRSoj4/discussion django-developers thread] to get other
opinions.
--
Ticket URL: <https://code.djangoproject.com/ticket/28172#comment:1>
* status: new => assigned
* owner: nobody => Alejandro Zamora Fonseca
--
Ticket URL: <https://code.djangoproject.com/ticket/28172#comment:2>
Comment (by Tim Graham):
Alejandro, I don't think there's consensus to make this change (hence the
ticket's Someday/Maybe status). Did you read the mailing list discussion
linked from in comment 1?
--
Ticket URL: <https://code.djangoproject.com/ticket/28172#comment:3>
* status: assigned => new
* owner: Alejandro Zamora Fonseca => (none)
--
Ticket URL: <https://code.djangoproject.com/ticket/28172#comment:4>