たとえば、電子メール文字列のリスト(セットまたは別の反復可能)があり、それらの電子メールのいずれかに一致する属性「email」を持つすべてのモデルのオブジェクトを取得したいと思います。
私がやっている:
from myapp.models import MyModel
l=['email1@x.com', 'email2@x.com', 'email3@y.com']
from django.db.models import Q
q = Q(email=l[0])
for e in l[1:]:
q |= Q(email=e)
MyModel.objects.get(q)
よりエレガントにそれを行う方法はありますか?