Added Model.__str__() default fallback, and changed Model.__repr__() to embed Model.__str__() within it

git-svn-id: http://code.djangoproject.com/svn/django/trunk@2893 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2006-05-10 16:10:07 +00:00
parent 887131c749
commit de3edb74c5
1 changed files with 4 additions and 1 deletions

View File

@ -69,7 +69,10 @@ class Model(object):
return getattr(self, self._meta.pk.attname) return getattr(self, self._meta.pk.attname)
def __repr__(self): def __repr__(self):
return '<%s object>' % self.__class__.__name__ return '<%s: %s>' % (self.__class__.__name__, self)
def __str__(self):
return '%s object' % self.__class__.__name__
def __eq__(self, other): def __eq__(self, other):
return isinstance(other, self.__class__) and self._get_pk_val() == other._get_pk_val() return isinstance(other, self.__class__) and self._get_pk_val() == other._get_pk_val()