Is it possible to filter within an annotation?
In my mind something like this (which doesn\'t actually work)
Student.objects.all().annotate(Count(\'at
Maybe this will work for you:
excused = Student.objects.filter(attendance__type='Excused').annotate(abs=Count('attendance'))
You need to filter the Students you're looking for first to just those with excused absences and then annotate the count of them.
Here's a link to the Django Aggregation Docs where it discusses filtering order.