summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2008-06-12 13:19:37 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2008-06-12 13:19:37 +0000
commitb9113ca81f553489001882ba95daa415d3652e81 (patch)
tree50d7c6699c821c32feda6ba60c114dd6511ccf53 /tests
parentac5b9f585735d49ac61e80cca7d977325c799beb (diff)
Fixed #7327 -- Added documentation and test case for defining subqueries. Thanks, Sebastian Noack.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@7625 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
-rw-r--r--tests/modeltests/many_to_one/models.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/modeltests/many_to_one/models.py b/tests/modeltests/many_to_one/models.py
index 53ad4466bb..dfb17b8344 100644
--- a/tests/modeltests/many_to_one/models.py
+++ b/tests/modeltests/many_to_one/models.py
@@ -175,6 +175,12 @@ False
>>> Article.objects.filter(reporter__in=[r,r2]).distinct()
[<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(),
+# 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>]
+
# You need two underscores between "reporter" and "id" -- not one.
>>> Article.objects.filter(reporter_id__exact=1)
Traceback (most recent call last):