[Answer]-Retriving data from aggregate function in the view itself in django

1👍

Your query returns a dictionary. You can get value in this way:

cont_rating_tmp = EmployerReviewContractor.objects.filter(
                         reviewed__id = cont.id
                            ).aggregate(average=Avg('avg_rate')) 

cont.rate=cont_rating_tmp["average"]

I copy a saple from django aggregation doc:

>>> from django.db.models import Max
>>> Book.objects.all().aggregate(Max('price'))
{'price__max': Decimal('81.20')}        <---  the result (a dictionary)

Leave a comment