Fixed #8406: Corrected some expected output to use repr format. Thanks to arien for the patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@8658 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
71615dbc70
commit
5c43a0a43f
|
@ -77,7 +77,7 @@ access your data. The API is created on the fly, no code generation necessary::
|
||||||
|
|
||||||
# Now the new reporter is in the database.
|
# Now the new reporter is in the database.
|
||||||
>>> Reporter.objects.all()
|
>>> Reporter.objects.all()
|
||||||
[John Smith]
|
[<Reporter: John Smith>]
|
||||||
|
|
||||||
# Fields are represented as attributes on the Python object.
|
# Fields are represented as attributes on the Python object.
|
||||||
>>> r.full_name
|
>>> r.full_name
|
||||||
|
@ -85,15 +85,15 @@ access your data. The API is created on the fly, no code generation necessary::
|
||||||
|
|
||||||
# Django provides a rich database lookup API.
|
# Django provides a rich database lookup API.
|
||||||
>>> Reporter.objects.get(id=1)
|
>>> Reporter.objects.get(id=1)
|
||||||
John Smith
|
<Reporter: John Smith>
|
||||||
>>> Reporter.objects.get(full_name__startswith='John')
|
>>> Reporter.objects.get(full_name__startswith='John')
|
||||||
John Smith
|
<Reporter: John Smith>
|
||||||
>>> Reporter.objects.get(full_name__contains='mith')
|
>>> Reporter.objects.get(full_name__contains='mith')
|
||||||
John Smith
|
<Reporter: John Smith>
|
||||||
>>> Reporter.objects.get(id=2)
|
>>> Reporter.objects.get(id=2)
|
||||||
Traceback (most recent call last):
|
Traceback (most recent call last):
|
||||||
...
|
...
|
||||||
DoesNotExist: Reporter does not exist for {'id__exact': 2}
|
DoesNotExist: Reporter matching query does not exist.
|
||||||
|
|
||||||
# Create an article.
|
# Create an article.
|
||||||
>>> from datetime import datetime
|
>>> from datetime import datetime
|
||||||
|
@ -103,7 +103,7 @@ access your data. The API is created on the fly, no code generation necessary::
|
||||||
|
|
||||||
# Now the article is in the database.
|
# Now the article is in the database.
|
||||||
>>> Article.objects.all()
|
>>> Article.objects.all()
|
||||||
[Django is cool]
|
[<Article: Django is cool>]
|
||||||
|
|
||||||
# Article objects get API access to related Reporter objects.
|
# Article objects get API access to related Reporter objects.
|
||||||
>>> r = a.reporter
|
>>> r = a.reporter
|
||||||
|
@ -112,13 +112,13 @@ access your data. The API is created on the fly, no code generation necessary::
|
||||||
|
|
||||||
# And vice versa: Reporter objects get API access to Article objects.
|
# And vice versa: Reporter objects get API access to Article objects.
|
||||||
>>> r.article_set.all()
|
>>> r.article_set.all()
|
||||||
[Django is cool]
|
[<Article: Django is cool>]
|
||||||
|
|
||||||
# The API follows relationships as far as you need, performing efficient
|
# The API follows relationships as far as you need, performing efficient
|
||||||
# JOINs for you behind the scenes.
|
# JOINs for you behind the scenes.
|
||||||
# This finds all articles by a reporter whose name starts with "John".
|
# This finds all articles by a reporter whose name starts with "John".
|
||||||
>>> Article.objects.filter(reporter__full_name__startswith="John")
|
>>> Article.objects.filter(reporter__full_name__startswith="John")
|
||||||
[Django is cool]
|
[<Article: Django is cool>]
|
||||||
|
|
||||||
# Change an object by altering its attributes and calling save().
|
# Change an object by altering its attributes and calling save().
|
||||||
>>> r.full_name = 'Billy Goat'
|
>>> r.full_name = 'Billy Goat'
|
||||||
|
|
|
@ -190,7 +190,7 @@ objects::
|
||||||
|
|
||||||
# This list contains a Blog object.
|
# This list contains a Blog object.
|
||||||
>>> Blog.objects.filter(name__startswith='Beatles')
|
>>> Blog.objects.filter(name__startswith='Beatles')
|
||||||
[Beatles Blog]
|
[<Blog: Beatles Blog>]
|
||||||
|
|
||||||
# This list contains a dictionary.
|
# This list contains a dictionary.
|
||||||
>>> Blog.objects.filter(name__startswith='Beatles').values()
|
>>> Blog.objects.filter(name__startswith='Beatles').values()
|
||||||
|
@ -650,9 +650,9 @@ primary-key value to an instance of the object with the given ID.
|
||||||
Example::
|
Example::
|
||||||
|
|
||||||
>>> Blog.objects.in_bulk([1])
|
>>> Blog.objects.in_bulk([1])
|
||||||
{1: Beatles Blog}
|
{1: <Blog: Beatles Blog>}
|
||||||
>>> Blog.objects.in_bulk([1, 2])
|
>>> Blog.objects.in_bulk([1, 2])
|
||||||
{1: Beatles Blog, 2: Cheddar Talk}
|
{1: <Blog: Beatles Blog>, 2: <Blog: Cheddar Talk>}
|
||||||
>>> Blog.objects.in_bulk([])
|
>>> Blog.objects.in_bulk([])
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue