惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Secure Thoughts
罗磊的独立博客
T
The Blog of Author Tim Ferriss
人人都是产品经理
人人都是产品经理
博客园 - 叶小钗
Last Week in AI
Last Week in AI
美团技术团队
Google Online Security Blog
Google Online Security Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
D
Docker
G
Google Developers Blog
大猫的无限游戏
大猫的无限游戏
酷 壳 – CoolShell
酷 壳 – CoolShell
小众软件
小众软件
月光博客
月光博客
L
LINUX DO - 最新话题
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
W
WeLiveSecurity
H
Heimdal Security Blog
Vercel News
Vercel News
SecWiki News
SecWiki News
Forbes - Security
Forbes - Security
Blog — PlanetScale
Blog — PlanetScale
Google DeepMind News
Google DeepMind News
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
www.infosecurity-magazine.com
www.infosecurity-magazine.com
TaoSecurity Blog
TaoSecurity Blog
T
Troy Hunt's Blog
A
About on SuperTechFans
C
Check Point Blog
S
Security Affairs
Hacker News - Newest:
Hacker News - Newest: "LLM"
AI
AI
WordPress大学
WordPress大学
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Help Net Security
Help Net Security
博客园_首页
The Last Watchdog
The Last Watchdog
S
SegmentFault 最新的问题
Hugging Face - Blog
Hugging Face - Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
Engineering at Meta
Engineering at Meta
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
I
Intezer
K
Kaspersky official blog
M
MIT News - Artificial intelligence
J
Java Code Geeks
G
GRAHAM CLULEY
P
Palo Alto Networks Blog

Django - 标签 - cywhat's blog

Python创建并上传自己的pip依赖包 Django操作异步任务 ValueError:invalid Django删除表重建 Django的csrf防御机制 Django连接Mysql配置 RuntimeWarning:DateTimeField Session.expire_date received a naive datetime fonts.googleapis.com访问较慢[已解决] Django中的form表单校验
UnorderedObjectListWarning:Pagination May Yield Inconsistent Results With an Unordered Object_list
cywhat · 2023-04-11 · via Django - 标签 - cywhat's blog

1、问题

1
使用django进行分页查询的时候,报错如下内容

UnorderedObjectListWarning: Pagination may yield inconsistent results with an unordered object_list

2、原因

1
django分页可能会产生与无序对象列表不一致的结果,因为使用了djangorestframe,展示结果为排序造成的

3、解决

1、在视图函数的查询中加入排序

1
case_list = PresInfo.objects.all().order_by('id')

2、在模型上加入排序

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
class PresInfo(models.Model):
    id = models.BigAutoField(primary_key=True, db_index=True)
    deviceId = models.CharField(verbose_name='设备ID', max_length=64)
    user = models.CharField(verbose_name='提交人', max_length=64)
    count = models.CharField(verbose_name='压测数量', max_length=64)
    counted = models.CharField(verbose_name='已执行数量', max_length=64, null=True)
    env = models.CharField(verbose_name='环境', max_length=64, default="IOT")
    status = models.SmallIntegerField(verbose_name='状态', default=0,help_text="0:未开始, 1:进行中, 2:已停止")
    create_datetime = models.DateTimeField(verbose_name='创建时间', auto_now_add=True)

class Meta:
        ordering=['id']   

3、重启项目,重新打开网页

关注一下再走吧

公众号 小程序

赞赏支持

微信打赏 支付宝打赏