diff options
| author | Josh Smeaton <josh.smeaton@gmail.com> | 2013-12-26 00:13:18 +1100 |
|---|---|---|
| committer | Marc Tamlyn <marc.tamlyn@gmail.com> | 2014-11-15 14:00:43 +0000 |
| commit | f59fd15c4928caf3dfcbd50f6ab47be409a43b01 (patch) | |
| tree | fe4a04d98359e1ffcbfe991303eb97d9a8e16afc /docs/topics | |
| parent | 39e3ef88c237e3f4cedc89cd36494a6d3f490812 (diff) | |
Fixed #14030 -- Allowed annotations to accept all expressions
Diffstat (limited to 'docs/topics')
| -rw-r--r-- | docs/topics/db/aggregation.txt | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/docs/topics/db/aggregation.txt b/docs/topics/db/aggregation.txt index 436256483d..175cc21782 100644 --- a/docs/topics/db/aggregation.txt +++ b/docs/topics/db/aggregation.txt @@ -67,6 +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 + >>> Book.objects.all().aggregate( + ... price_per_page=Sum(F('price')/F('pages'), output_field=FloatField())) + {'price_per_page': 0.4470664529184653} + # All the following queries involve traversing the Book<->Publisher # many-to-many relationship backward |
