Reputation: 18705
I want to count a number of all incorrect choices in question.
I have a query for a number of all choices:
questions.annotate(choices_count=Count('choices'))
Now, when I want to filter incorrect choices only into the Count function, it returns:
Cannot resolve keyword 'choice' into field.
questions.annotate(choices_count=Count(Case(When(choice__correct=False,then=1))))
Do you know how to do that?
Upvotes: 0
Views: 249
Reputation: 134
Probably you are writing 'choice' instead of 'choices' while checking it to False
Upvotes: 2