You can reroll your original example like this: def __str__(self):
pk = self.pk customer_name = None customer_phone = None try: customer_name = self.lead.customer_name customer_phone = self.lead.customer_phone except AttributeError: pass return _(u'#{0}, {1}, {2}').format( pk, customer_name, customer_phone, ) Much more pythonic, IMO. -James -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2Be%2BciUbzRe-EsnzG7ace1DS4gUkCFMeVyjo02m9TcOR3jsT8w%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.