Avg, Sum in Django

What is this article about?

We can find the average, sum of any particular column by using aggregate in django.

We have to import from django.db.models

ex: –

from django.db.models import Avg, Sum

avg_marks = TableName.objects.filter(user_id=id).aggregate(Avg(‘marks’))

total_marks = TableName.objects.filter(user_id=id).aggregate(Sum(‘marks’))

Posted in


Submitted by


Why trying to master digital Marketing, when LeadMirror with A2i can help you get there with ease?

Join Lead Mirror Today

Setting up your account takes less than a minute.