summaryrefslogtreecommitdiff
path: root/tests/modeltests/many_to_one
diff options
context:
space:
mode:
authorGary Wilson Jr <gary.wilson@gmail.com>2008-08-01 23:16:59 +0000
committerGary Wilson Jr <gary.wilson@gmail.com>2008-08-01 23:16:59 +0000
commit2db4b134809e162a6aa142300a1df14638eeae94 (patch)
tree380335351c5dc9afd081c7d5ebf8ecf876ef1161 /tests/modeltests/many_to_one
parentb5c5e8b4c06823fc3a14268a6e106e3fb6807813 (diff)
downloaddjango-2db4b134809e162a6aa142300a1df14638eeae94.tar.gz
Fixed #8070 -- Cache related objects passed to Model init as keyword arguments. Also:
* Model init no longer performs a database query to refetch the related objects it is passed. * Model init now caches unsaved related objects correctly, too. (Previously, accessing the field would raise `DoesNotExist` error for `null=False` fields.) * Added tests for assigning `None` to `null=True` `ForeignKey` fields (refs #6886). git-svn-id: http://code.djangoproject.com/svn/django/trunk@8185 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/modeltests/many_to_one')
-rw-r--r--tests/modeltests/many_to_one/models.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/tests/modeltests/many_to_one/models.py b/tests/modeltests/many_to_one/models.py
index 081cffb807..2dd1226e97 100644
--- a/tests/modeltests/many_to_one/models.py
+++ b/tests/modeltests/many_to_one/models.py
@@ -46,8 +46,12 @@ __test__ = {'API_TESTS':"""
# Article objects have access to their related Reporter objects.
>>> r = a.reporter
+
+# These are strings instead of unicode strings because that's what was used in
+# the creation of this reporter (and we haven't refreshed the data from the
+# database, which always returns unicode strings).
>>> r.first_name, r.last_name
-(u'John', u'Smith')
+('John', 'Smith')
# Create an Article via the Reporter object.
>>> new_article = r.article_set.create(headline="John's second story", pub_date=datetime(2005, 7, 29))
@@ -176,7 +180,7 @@ False
[<Article: John's second story>, <Article: Paul's story>, <Article: This is a test>]
# You can also use a queryset instead of a literal list of instances.
-# The queryset must be reduced to a list of values using values(),
+# The queryset must be reduced to a list of values using values(),
# then converted into a query
>>> Article.objects.filter(reporter__in=Reporter.objects.filter(first_name='John').values('pk').query).distinct()
[<Article: John's second story>, <Article: This is a test>]