Django

Code

Show
Ignore:
Timestamp:
06/12/08 08:19:37 (3 months ago)
Author:
russellm
Message:

Fixed #7327 -- Added documentation and test case for defining subqueries. Thanks, Sebastian Noack.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/tests/modeltests/many_to_one/models.py

    r7485 r7625  
    175175>>> Article.objects.filter(reporter__in=[r,r2]).distinct() 
    176176[<Article: John's second story>, <Article: Paul's story>, <Article: This is a test>] 
     177 
     178# You can also use a queryset instead of a literal list of instances. 
     179# The queryset must be reduced to a list of values using values(),  
     180# then converted into a query 
     181>>> Article.objects.filter(reporter__in=Reporter.objects.filter(first_name='John').values('pk').query).distinct() 
     182[<Article: John's second story>, <Article: This is a test>] 
    177183 
    178184# You need two underscores between "reporter" and "id" -- not one.