Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

django queryset group by

from django.db.models import Avg
teams = Analysts.objects.values('class').annotate(avgcap=Avg('gpa'))
# Assuming Analysts model has class and gpa field..
# This will group by class field and give the avg of gpa field values
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #django #queryset #group
ADD COMMENT
Topic
Name
7+7 =