私は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")
これどうやってするの
私は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")
これどうやってするの
Q
オブジェクトを利用して、1行でクエリを作成できます。
from django.db.models import Q
accounts = Account.objects.filter(Q(some query) | Q(some other query))