1
0
mirror of https://github.com/django/django.git synced 2025-10-27 23:56:08 +00:00

magic-removal: Moved model unit tests from 'testapp' package into 'modeltests' package, with each model test getting its own app

git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@1606 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty
2005-12-12 04:07:46 +00:00
parent 0309650237
commit 9b1dd36665
43 changed files with 0 additions and 5 deletions

View File

@@ -0,0 +1,31 @@
"""
2. Adding __repr__() to models
Although it's not a strict requirement, each model should have a ``__repr__()``
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
automatically-generated admin.
"""
from django.core import meta
class Article(meta.Model):
headline = meta.CharField(maxlength=100)
pub_date = meta.DateTimeField()
def __repr__(self):
return self.headline
API_TESTS = """
# Create an Article.
>>> from datetime import datetime
>>> a = Article(headline='Area man programs in Python', pub_date=datetime(2005, 7, 28))
>>> a.save()
>>> repr(a)
'Area man programs in Python'
>>> a
Area man programs in Python
"""