2đź‘Ť
âś…
Count all tasks that have task_type
by the name of “XYZ”, limited to clients in queryset
Task.objects.filter(client__in=clients, task_type__name='XYZ').count()
Sum all the value_num
for all the tasks by the name of “ABC”, limited to clients in the queryset.
from django.db.models import Sum
Task.objects.filter(client__in=clients, task_type__name='ABC').annotate(Sum('task_value__value_num'))
👤Chris Pratt
Source:stackexchange.com