Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
以下
模型.objects.all()[:10]
将返回按主键排序的 10 条记录。我正在尝试以相反的顺序获取对象。换句话说,如果我的最高主键是 5000,我试图获得 5000、4999、4998...
我努力了:
Model.objects.reverse().all()[:10]
但似乎不影响订单
你可以做:
Model.objects.order_by('-id')[:10]