diff options
| author | Adrian Holovaty <adrian@holovaty.com> | 2006-06-03 22:14:04 +0000 |
|---|---|---|
| committer | Adrian Holovaty <adrian@holovaty.com> | 2006-06-03 22:14:04 +0000 |
| commit | 142e59b462e71fe4a253c8a3d7856ab900f5c4b2 (patch) | |
| tree | 0c6f78ef6c55179a271298e101616382ac2d25b2 /tests | |
| parent | fc2a02f9666a2cd610443fc2107560b9832a017a (diff) | |
Fixed #2077 -- Renamed 'repr' model tests to 'str'
git-svn-id: http://code.djangoproject.com/svn/django/trunk@3072 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/modeltests/str/__init__.py (renamed from tests/modeltests/repr/__init__.py) | 0 | ||||
| -rw-r--r-- | tests/modeltests/str/models.py (renamed from tests/modeltests/repr/models.py) | 10 |
2 files changed, 5 insertions, 5 deletions
diff --git a/tests/modeltests/repr/__init__.py b/tests/modeltests/str/__init__.py index e69de29bb2..e69de29bb2 100644 --- a/tests/modeltests/repr/__init__.py +++ b/tests/modeltests/str/__init__.py diff --git a/tests/modeltests/repr/models.py b/tests/modeltests/str/models.py index 7e5b98c4a5..4e4228ac89 100644 --- a/tests/modeltests/repr/models.py +++ b/tests/modeltests/str/models.py @@ -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 API_TESTS = """ @@ -23,9 +23,9 @@ API_TESTS = """ >>> a = Article(headline='Area man programs in Python', pub_date=datetime(2005, 7, 28)) >>> a.save() ->>> repr(a) +>>> str(a) 'Area man programs in Python' >>> a -Area man programs in Python +<Article: Area man programs in Python> """ |
