1
0
mirror of https://github.com/django/django.git synced 2025-03-13 02:40:47 +00:00

[1.10.x] Added imports to docs/topics/db/aggregation.txt example.

Backport of 30d110ef43d8a3c50ea8ec4e4fe49bd2bb859530 from master
This commit is contained in:
MariKiev 2016-05-14 17:16:55 +07:00 committed by Tim Graham
parent de5d70461f
commit 699e43b017

View File

@ -68,6 +68,7 @@ In a hurry? Here's how to do common aggregate queries, assuming the models above
{'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}