django orm 分頁(paginator)取數據出現警告manage.py:1: UnorderedObjectListWarning: Pagination may yield inconsi

 

使用django的orm作分頁(Paginator)時出現了下面的警告python

 

In [19]: p=Paginator(guest_list,2)
manage.py:1: UnorderedObjectListWarning: Pagination may yield inconsistent results with an unordered object_list: <class 'sign.models.Guest'> QuerySet.
#!/usr/bin/env python

 

 

 

網上搜的是取數據前要先排序,加入下面代碼後取數據就不會出現警告了django

guest_list = Guest.objects.all().order_by("id") 
相關文章
相關標籤/搜索