Skip to content

Instantly share code, notes, and snippets.

@artschwagerb
Created December 12, 2013 15:40
Show Gist options
  • Save artschwagerb/7929982 to your computer and use it in GitHub Desktop.
Save artschwagerb/7929982 to your computer and use it in GitHub Desktop.
Django __unicode__ method
def __unicode__(self):
if self.name:
return u'%s' % (self.name)
elif self.assettag:
return u'%s' % (self.assettag)
elif self.mac_wired:
return u'%s' % (self.mac_wired)
elif self.model.chassis:
return u'%s' % (self.model.chassis)
else:
return u'%s' % ("Unknown Device")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment