Right, I see the log entries. Good to know there's a way to log them, for 
those who use sentry it will be even easier to notice this problem,
just ensure you're logging WARNING messages.

Thanks
Federico


On Friday, March 11, 2016 at 1:18:27 PM UTC+1, Tim Graham wrote:
>
> Yes, I think it's {% include %} rendering an empty string if there's an 
> exception. In Django 1.9, we added a logger for these exceptions to make 
> debugging easier: 
> https://docs.djangoproject.com/en/stable/topics/logging/#django-template.
>
> On Friday, March 11, 2016 at 6:30:35 AM UTC-5, Federico Capoano wrote:
>>
>> This never happened to me and I find it very strange. Maybe it's a bug or 
>> maybe it's the intended behaviour, but I find it REALLY strange.
>>
>> Consider a widget which, for some reason, raises an exception:
>>
>> class CoolWidget(AdminTextareaWidget):
>>     def render(self, name, value, attrs={}):
>>         WRONG()
>>         return super(JsonSchemaWidget, self).render(name, value, attrs)
>>
>> The widget is included in an admin form like:
>>
>> class PizzaForm(forms.ModelForm):
>>     class Meta:
>>         model = Pizza
>>         exclude = []
>>         widgets = {'toppings': CoolWidget}
>>
>>
>> class PizzaAdmin(ModelAdmin):
>>     form = TemplateForm
>>
>> Now, if DEBUG is True, trying to open the relative pizza change or add 
>> form will result in:
>>
>> NameError: name 'WRONG' is not defined
>>
>> When DEBUG to False what I see is really strange:
>>
>> I get an empty change/add form!
>>
>>
>> <https://lh3.googleusercontent.com/-k2-DznqIO2E/VuKq3sx74OI/AAAAAAAABlo/AFAvi1vQ3EI6o2mshUBCLQgd8vpvvF5VQ/s1600/widget-problem-django.png>
>>
>>
>> Now suppose that the condition that raises the exception happens only on 
>> a remote server
>>
>> which has DEBUG=False. The exception happens because the configuration of 
>> a django project
>>
>> has not been updated correctly yet.
>>
>>
>> Instead of failing loud, it will fail silently, leaving an empty 
>> add/change form.
>>
>>
>> Is it the intended behaviour? Or a bug?
>>
>> I guess it is related due to the fact that template errors are silenced.
>>
>> Federico
>>
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
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/c6158dd8-cc88-4c26-ac25-4b86eef2ea3f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to