On Mar 6, 7:41 am, Russell Keith-Magee <russ...@keith-magee.com> wrote: > On 06/03/2012, at 12:56 PM, Aryeh Leib Taurog wrote: > > > Did exception handling in templates change somewhere between Django > > 1.2.x and 1.3.x? > > > I have a callable which is displayed in a template. Sometimes it > > raises AttributeException. Under 1.2.x the callable was treated as an > > empty string, but under 1.3.1 this results in a 500 response. This is > > a major behavior change, so I'm surprised it doesn't seem to be > > documented anywhere. What am I missing? > > As always, the release notes are the place to check if anything has changed > between releases. > > https://docs.djangoproject.com/en/1.3/releases/1.3/#callables-in-temp... >
Yes, I saw that, but I don't think it describes at all the behavior I am seeing. Let's say I have the following code: class MyClass: def my_title(self): if 'some string' not in self.get_another_object().x: return 'Specific Title' Then I have a template: {% with instance_of_myclass as obj %} {% if obj.my_title %} {{ obj.my_title }} {% else %} Generic Title {% endif %} Sometimes self.get_another_object() returns an object which doesn't have attribute 'x' so my_title() raises an AttributeError exception. Under Django 1.2.4 the template renders as 'Generic Title,' but under 1.3.1 I get a server error. -- 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.