mirror of
https://github.com/django/django.git
synced 2025-09-06 18:50:55 +00:00
Fixed #24649 -- Allowed using Avg aggregate on non-numeric field types.
This commit is contained in:
parent
26996e2d55
commit
2d76b61dc2
7 changed files with 46 additions and 15 deletions
|
@ -75,12 +75,8 @@ class Avg(Aggregate):
|
|||
name = 'Avg'
|
||||
|
||||
def __init__(self, expression, **extra):
|
||||
super(Avg, self).__init__(expression, output_field=FloatField(), **extra)
|
||||
|
||||
def convert_value(self, value, expression, connection, context):
|
||||
if value is None:
|
||||
return value
|
||||
return float(value)
|
||||
output_field = extra.pop('output_field', FloatField())
|
||||
super(Avg, self).__init__(expression, output_field=output_field, **extra)
|
||||
|
||||
|
||||
class Count(Aggregate):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue