python - Flask:使用flask-sqlalchermy分页结果错误
问题描述
我的代码是这样的:</p>
page = db.session.query(agent).filter(...).order_by(agent.create_time).paginate(1, 10)
结果是:page.total 为 9。
但是当我把代码改成这样的时候:</p>
page = db.session.query(agent).filter(...).order_by(agent.create_time).paginate(1, 20)
结果是:page.total 为 19。
在数据库终端执行sql的结果是19
我应该怎么办?
解决方案
If the query wasn't wrong, show the filter
conditions.
The total
is the result:
db.session.query(agent).filter(...).order_by(None).count()
total
has nothing to do with page/per_page
.
推荐阅读
- javascript - Testcafe LocalStorage 的问题
- javascript - 使用“输入”事件动态更改背景颜色
- c - 创建一个以升序存储项目或按该顺序打印的链表
- javascript - 如果第一个 JS 脚本没有产生匹配项,我如何运行第二个 JS 脚本?
- python - 我们如何在 Python 中将信号拟合到 sigmoid 函数中?
- javascript - 向所有 Firebase 云消息传递令牌 (Web) 发送通知
- streaming - Liquidsoap——读取元数据
- nativescript - Unable to open dataurl using utils.openUrl()
- python - 堆叠稀疏矩阵
- laravel - 使用 laravel 作业处理图像上传时无法解决的依赖关系