欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

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_([条件])

相关标签: filter