aggregate() - It is a terminal clause for a queryset that, when invoked, return dictionary name-value pair.
Required Module: django.db.models import Avg, Min, Max, Sum, Count
Open views.py file and write this code
e.g. def home(request):
stud_data=Student.objects.all();
average=stud_data.aggregate(average('marks'))
total=stud_data.aggregate(Sum('marks'))
minimum=stud_data.aggregate(Min('marks'))
maximum=stud_data.aggregate(Max('marks'))
totalCount=stud_data.aggregate(Count('marks'))
context {
'students':stud_data,'average':average,'total':total,'minimum':minimum,'maximum':maximum,'totalCount':totalCount
}
2 Comments
Very nice,������
ReplyDeletei dont want dictionary how to render only the number
ReplyDeleteComment Rules :
1. Do not post Adult/illegal Links.
2. Try to comment in only मराठी / English Language.
3. Do not post other website's links which are useless.
4. Your Comment should be based on the Topic for other queries.
5. Do not use Abusive Language.
6. Respect each other.
Thank You for following the rules. Please Comment....