summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2017-06-06 16:11:48 -0400
committerTim Graham <timograham@gmail.com>2017-06-07 09:43:48 -0400
commitbc9c6fe7cb11fb0a59b39ca6f7661cb6013f513c (patch)
tree811698b5148b1da37924845d26dd836acbb6feae /docs
parent992f143bad4143da7e43e21c41dfdab79ddd5070 (diff)
[1.11.x] Fixed #28233 -- Used a simpler example in the aggregation "cheat sheet" docs.
Backport of 49b9c89d4094574117c9d5b7a696ce152e02553a from master
Diffstat (limited to 'docs')
-rw-r--r--docs/topics/db/aggregation.txt10
1 files changed, 5 insertions, 5 deletions
diff --git a/docs/topics/db/aggregation.txt b/docs/topics/db/aggregation.txt
index aa56a8b4eb..6f7d3918af 100644
--- a/docs/topics/db/aggregation.txt
+++ b/docs/topics/db/aggregation.txt
@@ -67,11 +67,11 @@ In a hurry? Here's how to do common aggregate queries, assuming the models above
>>> Book.objects.all().aggregate(Max('price'))
{'price__max': Decimal('81.20')}
- # Cost per page
- >>> from django.db.models import F, FloatField, Sum
- >>> Book.objects.all().aggregate(
- ... price_per_page=Sum(F('price')/F('pages'), output_field=FloatField()))
- {'price_per_page': 0.4470664529184653}
+ # Difference between the highest priced book and the average price of all books.
+ >>> from django.db.models import FloatField
+ >>> Book.objects.aggregate(
+ ... price_diff=Max('price', output_field=FloatField()) - Avg('price')))
+ {'price_diff': 46.85}
# All the following queries involve traversing the Book<->Publisher
# foreign key relationship backwards.