Django filter against Multiple Item QuerySets
I have two Model's which are related with a ForeignKey field. Let's call these objects Event and EventRegistration.
I can easily, for example, do this:
EventRegistration.objects.filter开发者_如何学运维(event=Event.objects.get(name="Some Event"))
But, I cannot do something like this:
EventRegistration.objects.filter(event=Event.objects.all())
I know this is a contrived example, but is there a way to filter against whole QuerySets in a similar way to the second line of code?
EventRegistration.objects.filter(event__in=Event.objects.all())
精彩评论