Ticket #9105: model__unicode__method.diff

File model__unicode__method.diff, 779 bytes (added by Thomas Güttler, 16 years ago)
  • django/db/models/base.py

     
    268268    def __repr__(self):
    269269        return smart_str(u'<%s: %s>' % (self.__class__.__name__, unicode(self)))
    270270
     271    def __unicode__(self):
     272        return u'%s %s' % (self.__class__.__name__, self._get_pk_val())
     273
    271274    def __str__(self):
    272         if hasattr(self, '__unicode__'):
    273             return force_unicode(self).encode('utf-8')
    274         return '%s object' % self.__class__.__name__
     275        return force_unicode(self).encode('utf-8')
    275276
    276277    def __eq__(self, other):
    277278        return isinstance(other, self.__class__) and self._get_pk_val() == other._get_pk_val()
Back to Top