As `DurationField` uses different underlying datatype for its storage
(bigint, interval, ...) averaging on such fields
[https://groups.google.com/d/msg/django-users/BwkK7R1WXYU/k4b5nzNwAQAJ
might require or not] an explicit `output_field` and can be a source of
confusion.
As the SQL `AVG` function only defaults to using floating value datatype
as a return value when numeric input is used I suggest adjusting the `Avg`
expression's `output_field` resolution to only use `FloatField` for
default when its source field is an instance of one of Django's numerical
field classes. This would lift the requirement of explicitly specifying an
`output_field` when averaging `DurationField` on PostgreSQL.
--
Ticket URL: <https://code.djangoproject.com/ticket/26458>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* has_patch: 0 => 1
Comment:
https://github.com/django/django/pull/6413
--
Ticket URL: <https://code.djangoproject.com/ticket/26458#comment:1>
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/26458#comment:2>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/26458#comment:3>
* status: new => closed
* resolution: => fixed
Comment:
In [changeset:"a6074e8908e36286de7e31f165be801df8ee1eab" a6074e89]:
{{{
#!CommitTicketReference repository=""
revision="a6074e8908e36286de7e31f165be801df8ee1eab"
Fixed #26458 -- Based Avg's default output_field resolution on its source
field type.
Thanks Tim for the review and Josh for the input.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/26458#comment:4>