开发者

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())
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜