On 21 oct, 15:05, Peter Bengtsson <pete...@gmail.com> wrote: > Suppose I've got this code: > > # template.html > Info: {{ article_instance.count_words }} words > > # models.py > class Article(models.Model): > text = models.TextField() > def count_words(self): > raise AttributeError('debugging')
<hs> a NotImplementedError would be more appropriate !-) </hs> > Then, when I render that page I get: > Info: words Did you actually tried with this exact code ? If yes, this contradicts the FineManual(tm): """ If, during the method lookup, a method raises an exception, the exception will be propagated, unless the exception has an attribute silent_variable_failure whose value is True. If the exception does have a silent_variable_failure attribute, the variable will render as an empty string. (...) Note that django.core.exceptions.ObjectDoesNotExist, which is the base class for all Django database API DoesNotExist exceptions, has silent_variable_failure = True. So if you're using Django templates with Django model objects, any DoesNotExist exception will fail silently. """ http://docs.djangoproject.com/en/dev/ref/templates/api/#rendering-a-context > When I want is a raised proper error so that I can spot the possible > bug in my system. How do I do that? Not tested, but this might be the answer: http://docs.djangoproject.com/en/dev/ref/settings/#debug-propagate-exceptions > If what you look up in the template doesn't exist I can accept that > Django, currently, prefers to just suppress it Actually, there's no "suppression", cf http://docs.djangoproject.com/en/dev/ref/templates/api/#how-invalid-variables-are-handled HTH --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---