Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

aggregation with f() in django rest api

>>> from django.db.models import Avg, Count
>>> Book.objects.annotate(num_authors=Count('authors')).aggregate(Avg('num_authors'))
{'num_authors__avg': 1.66}
Source by docs.djangoproject.com #
 
PREVIOUS NEXT
Tagged: #aggregation #django #rest #api
ADD COMMENT
Topic
Name
4+1 =