Found in another thread [0]: "Some time in late 2003, Adrian and I decided 
that errors in templates  were best handled silently - the idea was that it 
would prevent untrained template editors from being able to 500-error a 
site with a typo."

And another [1]: "The broad reasoning is that a partial page rendering is 
preferable to a 500 error when rendering a template. This is driven by 
production requirements -- the end user shouldn't ever see a 500 error."

As for me as a developer, I'd support removing the exception silencing that 
{% include %} does so that errors appear alongside any other exceptions 
(e.g. in Sentry) rather than in the django.template logger (that logging 
was added in Django 1.9).

[0] 
https://groups.google.com/d/msg/django-developers/8yMzgEWsLl4/H7ITMVMkZcwJ
[1] 
https://groups.google.com/d/msg/django-developers/KpDS2tWLp7U/y7zli4P79nkJ

On Monday, July 11, 2016 at 4:06:11 AM UTC-4, Sylvain Fankhauser wrote:
>
> Hi,
>
> I'm bringing this back to the table since I can't believe I'm the only one 
> to find this behaviour weird and possibly dangerous. I'd really be 
> interested in getting your opinion on this!
>
> Thanks,
> Sylvain
>
> 2016-06-09 14:37 GMT+02:00 Sylvain Fankhauser <sylvain.f...@gmail.com 
> <javascript:>>:
>
>> Hi all,
>>
>> I got really frustrated today trying to understand why a bug could get 
>> past my test suite but fail in my dev environment. Finally Baptiste 
>> Mispelon pointed me to the include template tag documentation 
>> <https://docs.djangoproject.com/en/1.9/ref/templates/builtins/#include>:
>>
>> If the included template causes an exception while it’s rendered 
>>> (including if it’s missing or has syntax errors), the behavior varies 
>>> depending on the template engine's debug option (if not set, this option 
>>> defaults to the value of DEBUG). When debug mode is turned on, an exception 
>>> like TemplateDoesNotExist or TemplateSyntaxError will be raised. When debug 
>>> mode is turned off, {% include %} logs a warning to the django.template 
>>> logger with the exception that happens while rendering the included 
>>> template and returns an empty string.
>>>
>>
>> That's a real problem when running tests, because since the exception is 
>> just silenced your tests will still pass although there was actually some 
>> error in your code. The current way to deal with this is, I guess, to set 
>> the template engine DEBUG option to True in the test environment but that 
>> doesn't seem right to me.
>>
>> I don't have a solution right now and I know this would be a big 
>> backwards incompatible change and the chances for this to change are 
>> abysmally low. But maybe we could just add an option for that (to make 
>> exceptions pop out of the include tag), set its default value to match the 
>> current behaviour, and change it with a clear deprecation plan?
>>
>> Cheers,
>> Sylvain
>>
>
>

-- 
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/d8452749-e30f-4a91-af32-6cb862cb431d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to