我想在django中做以下事情:
假设我有一个名为Account
accountset1 = Account.objects.filter(some query)
accountset2 = Account.objects.filter(some other query)
accounts = Account.objects.filter("account in either of accountset1 accountset2")
我该怎么做
答案 0 :(得分:2)
您可以使用Q
object并在一行中进行查询。
from django.db.models import Q
accounts = Account.objects.filter(Q(some query) | Q(some other query))