I think it's better to use Answer.objects.filter(question__entity=entity, is_deleted=False).count()