Ticket #13532: Fdoc.diff

File Fdoc.diff, 1.1 KB (added by Erik Wognsen, 14 years ago)
  • docs/topics/db/queries.txt

     
    512512and use that ``F()`` object in the query::
    513513
    514514    >>> 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'))
    516516
    517517Django supports the use of addition, subtraction, multiplication,
    518518division and modulo arithmetic with ``F()`` objects, both with constants
    519 and with other ``F()`` objects. To find all the blog entries with *twice* as
    520 many comments as pingbacks, we modify the query::
     519and with other ``F()`` objects. To find all the blog entries with more than
     520*twice* as many comments as pingbacks, we modify the query::
    521521
    522     >>> Entry.objects.filter(n_pingbacks__lt=F('n_comments') * 2)
     522    >>> Entry.objects.filter(n_comments__gt=F('n_pingbacks') * 2)
    523523
    524524To find all the entries where the sum of the pingback count and comment count
    525525is greater than the rating of the entry, we would issue the query::
Back to Top