Ticket #19415: 19415Docs.diff

File 19415Docs.diff, 1.0 KB (added by Benjamin Phillips, 9 years ago)
  • docs/topics/db/aggregation.txt

    diff --git a/docs/topics/db/aggregation.txt b/docs/topics/db/aggregation.txt
    index 030335c..e60d400 100644
    a b title that starts with "Django" using the query::  
    323323
    324324    >>> Book.objects.filter(name__startswith="Django").aggregate(Avg('price'))
    325325
     326When filtering against :ref:`multiple values <spanning-multi-valued-relationships>`,
     327be careful to structure your filters according to the behavior you desire::
     328
     329    # Annotated list of all books with a title starting with "Django" *and* more than 100 pages.
     330    >>> Book.objects.filter(name__startswith="Django",
     331                    pages__gt=100).annotate(num_authors=Count('authors'))
     332    # Annotated list of all books with a title starting with "Django" *as well as* all books with more than 100 pages.
     333    >>>Book.objects.filter(name__startswith="Django").filter(
     334                    pages__gt=100).annotate(num_authors=Count('authors'))
     335
    326336Filtering on annotations
    327337~~~~~~~~~~~~~~~~~~~~~~~~
    328338
Back to Top