Ticket #13532: Fdoc.diff
File Fdoc.diff, 1.1 KB (added by , 15 years ago) |
---|
-
docs/topics/db/queries.txt
512 512 and use that ``F()`` object in the query:: 513 513 514 514 >>> from django.db.models import F 515 >>> Entry.objects.filter(n_ pingbacks__lt=F('n_comments'))515 >>> Entry.objects.filter(n_comments__gt=F('n_pingbacks')) 516 516 517 517 Django supports the use of addition, subtraction, multiplication, 518 518 division and modulo arithmetic with ``F()`` objects, both with constants 519 and with other ``F()`` objects. To find all the blog entries with *twice* as520 many comments as pingbacks, we modify the query::519 and with other ``F()`` objects. To find all the blog entries with more than 520 *twice* as many comments as pingbacks, we modify the query:: 521 521 522 >>> Entry.objects.filter(n_ pingbacks__lt=F('n_comments') * 2)522 >>> Entry.objects.filter(n_comments__gt=F('n_pingbacks') * 2) 523 523 524 524 To find all the entries where the sum of the pingback count and comment count 525 525 is greater than the rating of the entry, we would issue the query::