[Django]-Django aggregate average of an annotation sum (1.6.5)

0๐Ÿ‘

โœ…

Looks like this is a known bug in Django 1.6, and need to upgrade to 1.7+ to fix

For now, I will just do the math in python.

๐Ÿ‘คC.B.

0๐Ÿ‘

I think this is what you need, please give a feedback after test the line below:

MyModel.objects.filter(...).values('user__id').distinct().annotate(sum=Sum('value')).aggregate(Avg('sum'))
๐Ÿ‘คGocht

Leave a comment