标签: mysql django django-models
有没有办法使用Django ORM进行以下查询?
SELECT * FROM table1 WHERE (x, y) IN ((1, 'a'), (2, 'b'))
答案 0 :(得分:0)
Q对象怎么样?
query = reduce(operator.or_, [Q(x=d[0], y=d[1]) for d in [(1, 'a'), (2, 'b')]] Table1.objects.filter(query)