Reputation: 25479
I have a Question
model and a Response
model, which contains a foreign key to a Question
.
I can get all of the responses for a given question with question.response_set
I want to do something to the effect of
Question.objects.exclude(response_set=None)
What's the best way to go about this?
Upvotes: 1
Views: 179
Reputation: 53971
Question.objects.exclude(response__isnull=True)
should return only questions with responses
Upvotes: 4