Changeset 7625
- Timestamp:
- 06/12/08 08:19:37 (5 months ago)
- Files:
-
- django/trunk/docs/db-api.txt (modified) (1 diff)
- django/trunk/tests/modeltests/many_to_one/models.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/docs/db-api.txt
r7559 r7625 1374 1374 SELECT ... WHERE id IN (1, 3, 4); 1375 1375 1376 You can also use a queryset to dynamically evaluate the list of values 1377 instead of providing a list of literal values. The queryset must be 1378 reduced to a list of individual values using the ``values()`` method, 1379 and then converted into a query using the ``query`` attribute:: 1380 1381 Entry.objects.filter(blog__in=Blog.objects.filter(name__contains='Cheddar').values('pk').query) 1382 1383 This queryset will be evaluated as subselect statement:: 1384 1385 SELET ... WHERE blog.id IN (SELECT id FROM ... WHERE NAME LIKE '%Cheddar%') 1386 1376 1387 startswith 1377 1388 ~~~~~~~~~~ django/trunk/tests/modeltests/many_to_one/models.py
r7485 r7625 175 175 >>> Article.objects.filter(reporter__in=[r,r2]).distinct() 176 176 [<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>] 177 183 178 184 # You need two underscores between "reporter" and "id" -- not one.
