python peewee或子句

python peewee或子句,python,peewee,Python,Peewee,我想在执行查询时动态地或多个子句。我在peewee文档中看到: import operator or_clauses = reduce(operator.or_, clauses) # OR together all clauses 然而,这一说明有点不清楚。子句应该设置为什么?有人有任何示例代码吗?子句将是示例中的表达式列表,很抱歉不清楚 你可以写一些类似的东西: clauses = [ (User.username == 'something'), (User.somet

我想在执行查询时动态地
多个子句。我在peewee文档中看到:

import operator
or_clauses = reduce(operator.or_, clauses)  # OR together all clauses

然而,这一说明有点不清楚。
子句
应该设置为什么?有人有任何示例代码吗?

子句将是示例中的表达式列表,很抱歉不清楚

你可以写一些类似的东西:

clauses = [
    (User.username == 'something'),
    (User.something == 'another thing'),
    ...
]
User.select().where(reduce(operator.or_, clauses))