Nested query support.

This extends previous functionality that allowed passing Query objects as the
rvals to filters. You can now pass QuerySets, which requires less poking at
opaque attributes. See the documentation of the "__in" lookup type for the
details.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@9701 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Malcolm Tredinnick 2009-01-05 11:47:48 +00:00
parent 062a94ef45
commit f747b61c20
4 changed files with 59 additions and 7 deletions

View file

@ -1008,6 +1008,13 @@ cases).
# optimise the inner query without losing results.
>>> Annotation.objects.exclude(tag__children__name="t2")
[<Annotation: a2>]
Nested queries are possible (although should be used with care, since they have
performance problems on backends like MySQL.
>>> Annotation.objects.filter(notes__in=Note.objects.filter(note="n1"))
[<Annotation: a1>]
"""}
# In Python 2.3 and the Python 2.6 beta releases, exceptions raised in __len__