Skip to content
Browse files

Fixed #2077 -- Renamed 'repr' model tests to 'str'

git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent fc2a02f commit 142e59b462e71fe4a253c8a3d7856ab900f5c4b2 @adrianholovaty adrianholovaty committed
0 tests/modeltests/repr/ → tests/modeltests/str/
File renamed without changes.
10 tests/modeltests/repr/ → tests/modeltests/str/
@@ -1,7 +1,7 @@
-2. Adding __repr__() to models
+2. Adding __str__() to models
-Although it's not a strict requirement, each model should have a ``__repr__()``
+Although it's not a strict requirement, each model should have a ``__str__()``
method to return a "human-readable" representation of the object. Do this not
only for your own sanity when dealing with the interactive prompt, but also
because objects' representations are used throughout Django's
@@ -14,7 +14,7 @@ class Article(models.Model):
headline = models.CharField(maxlength=100)
pub_date = models.DateTimeField()
- def __repr__(self):
+ def __str__(self):
return self.headline
@@ -23,9 +23,9 @@ def __repr__(self):
>>> a = Article(headline='Area man programs in Python', pub_date=datetime(2005, 7, 28))
->>> repr(a)
+>>> str(a)
'Area man programs in Python'
>>> a
-Area man programs in Python
+<Article: Area man programs in Python>

0 comments on commit 142e59b

Please sign in to comment.
Something went wrong with that request. Please try again.