Flask中使用filter过滤,不在某个范围内
程序员文章站
2022-03-10 14:13:19
...
参考代码如下
try:
objects = User.query.filter(~User.username.in_(["admin", "operator", "auditor"])).order_by(
User.create_time.desc())
count = objects.count()
paginate = objects.paginate(page, perpage, False)
current_page = paginate.page
total_page = paginate.pages
objects = paginate.items
except Exception as e:
print(e)
return False
使用~模型类名.字段名.in_([条件])
上一篇: 报LinkageError的原因
下一篇: HTTP协议(五):代理