Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#28233 closed Cleanup/optimization (fixed)

Improve the "price_per_page" example in the aggregation documentation

Reported by: Shi Liu Owned by: Rajesh Veeranki
Component: Documentation Version: 1.11
Severity: Normal Keywords: Documentation, Aggregation, Code Example
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

This example is not very clear. There has been some talk about it: https://groups.google.com/forum/#!topic/django-users/CqEGJCI5aNs

# 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}

Change History (6)

comment:1 by Tim Graham, 7 years ago

Summary: Improve the "price_per_page" example in the Documentation on AggregationImprove the "price_per_page" example in the aggregation documentation
Triage Stage: UnreviewedAccepted

comment:2 by Windson yang, 7 years ago

Is use 'Sum' function here just for syntax correct?

comment:3 by Rajesh Veeranki, 7 years ago

Has patch: set
Owner: changed from nobody to Rajesh Veeranki
Status: newassigned

Submitted PR: https://github.com/django/django/pull/8567
Please let me know if it needs improvement.

comment:4 by Tim Graham, 7 years ago

Triage Stage: AcceptedReady for checkin

comment:5 by Tim Graham <timograham@…>, 7 years ago

Resolution: fixed
Status: assignedclosed

In 49b9c89d:

Fixed #28233 -- Used a simpler example in the aggregation "cheat sheet" docs.

comment:6 by Tim Graham <timograham@…>, 7 years ago

In bc9c6fe:

[1.11.x] Fixed #28233 -- Used a simpler example in the aggregation "cheat sheet" docs.

Backport of 49b9c89d4094574117c9d5b7a696ce152e02553a from master

Note: See TracTickets for help on using tickets.
Back to Top