mirror of
https://github.com/django/django.git
synced 2025-08-03 18:38:50 +00:00
Fixed #14030 -- Allowed annotations to accept all expressions
This commit is contained in:
parent
39e3ef88c2
commit
f59fd15c49
43 changed files with 2572 additions and 801 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue