Reputation: 4115
I want to do something like this:
all_objects.annotate(c=Count(
Case(
When(hit__question=A AND
hit__participant=B, then=1 )
How would i go about this?
Upvotes: 2
Views: 45
Reputation: 2884
The When
object can behave just like a normal .filter
so we just need to add the different field lookups as separate arguments like so:
all_objects.annotate(c=Count(
Case(
When(hit__question=A,
hit__participant=B, then=1 )
# rest of query
Upvotes: 2