diff options
| author | Russell Keith-Magee <russell@keith-magee.com> | 2010-05-14 01:52:28 +0000 |
|---|---|---|
| committer | Russell Keith-Magee <russell@keith-magee.com> | 2010-05-14 01:52:28 +0000 |
| commit | f0774927e66f1738a2e264b982c3a2a0968465b0 (patch) | |
| tree | 239b6b4708ac84a071e7620e10b6809c907f30ce | |
| parent | c179bd5cfb1e0d255494e1d2cea970e172b0b729 (diff) | |
[1.1.X] Fixed #13532 -- Corrected and clarified examples in F() docs. Thanks to erw for the report and patch.
Backport of r13254 from trunk.
git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.1.X@13255 bcc190cf-cafb-0310-a4f2-bffc1f526a37
| -rw-r--r-- | docs/topics/db/queries.txt | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/docs/topics/db/queries.txt b/docs/topics/db/queries.txt index 58537bf819..ca75072dcc 100644 --- a/docs/topics/db/queries.txt +++ b/docs/topics/db/queries.txt @@ -512,17 +512,18 @@ than pingbacks, we construct an ``F()`` object to reference the comment count, and use that ``F()`` object in the query:: >>> from django.db.models import F - >>> Entry.objects.filter(n_pingbacks__lt=F('n_comments')) + >>> Entry.objects.filter(n_comments__gt=F('n_pingbacks')) Django supports the use of addition, subtraction, multiplication, division and modulo arithmetic with ``F()`` objects, both with constants -and with other ``F()`` objects. To find all the blog entries with *twice* as -many comments as pingbacks, we modify the query:: +and with other ``F()`` objects. To find all the blog entries with more than +*twice* as many comments as pingbacks, we modify the query:: - >>> Entry.objects.filter(n_pingbacks__lt=F('n_comments') * 2) + >>> Entry.objects.filter(n_comments__gt=F('n_pingbacks') * 2) -To find all the entries where the sum of the pingback count and comment count -is greater than the rating of the entry, we would issue the query:: +To find all the entries where the rating of the entry is less than the +sum of the pingback count and comment count, we would issue the +query:: >>> Entry.objects.filter(rating__lt=F('n_comments') + F('n_pingbacks')) |
