b = Task.objects.create(status='A')
b.prerequisites.add(a)
c = Task.objects.create(status='P')
c.prerequisites.add(b)
prerequisites_complete = Task.objects.exclude(prerequisites__status__in=[
    'A', 'P', 'F'])
set([t.id for t in prerequisites_complete]) == set([a.id, b.id])
In Django, how do I filter based on all entities in a many-to-many relation instead of any?