0

Hopefully easy question. I have a query set of actions and each action has a time_estimate. I want to get the average time_estimate across all of the actions in the queryset such that this returns the average:

{{ actions.avg_time_estimate }} 

I tried

actions.avg_time_estimate = actions.aggregate(Avg('time_estimate'))

but this is assigning a dictionary to actions.avg_time_estimate, meaning I get my average like this:

{{ actions.avg_time_estimate.effort__avg }} 

What is the correct way to pull the average into the queryset? I also want to retain the actual list of actions in the query.

4

1 に答える 1

0

Try actions = actions.aggregate(avg_time_estimate=Avg('time_estimate'))

于 2012-05-10T20:17:38.430 に答える