Hello, In my model I have:
def __str__(self): return _(u'#{0}, {1}, {2}').format( self.pk, self.lead and self.lead.customer_name or None, self.lead and self.lead.customer_phone or None ) Where self.lead is an optional FK: lead = models.ForeignKey('Lead', blank=True, null=True,) If I don't use the and/or syntax above, and the FK *doesn't exist*, I get: AttributeError: 'NoneType' object has no attribute 'customer_name' > While the above and/or syntax works, I'm left wondering if there's a better way to handle this scenario? I have several models where the FK may or may not exist upon save. Can anyone give me tips on how best to handle? Thanks! M -- 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/e5e2a0ea-8fb0-4acb-a84d-edccc64d7a62%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.