How to store and pass multiple Avg function in an aggregate the code below gives error of type
views.py
riasec_avg =[Avg('realistic'),Avg('investigative'),Avg('artistic'),Avg('social'),Avg('enterprising'),Avg('conventional')]
context['riasec_male'] = Riasec_result.objects.filter(user__profile__gender='M').aggregate(riasec_avg)
context['riasec_female'] = Riasec_result.objects.filter(user__profile__gender='F').aggregate(riasec_avg)
CodePudding user response:
Use args
riasec_avg =(Avg('realistic'),Avg('investigative'),Avg('artistic'),Avg('social'),Avg('enterprising'),Avg('conventional'))
context['riasec_male'] = Riasec_result.objects.filter(user__profile__gender='M').aggregate(*riasec_avg)
context['riasec_female'] = Riasec_result.objects.filter(user__profile__gender='F').aggregate(*riasec_avg)