【发布时间】:2011-11-07 11:30:54
【问题描述】:
我有两个与 ForeignKey 字段相关的模型。 我们将这些对象称为 Event 和 EventRegistration。
例如,我可以很容易地做到这一点:
EventRegistration.objects.filter(event=Event.objects.get(name="Some Event"))
但是,我不能这样做:
EventRegistration.objects.filter(event=Event.objects.all())
我知道这是一个人为的例子,但是有没有办法以类似于第二行代码的方式过滤整个 QuerySet?
【问题讨论】:
标签: python django django-models django-queryset