联想电脑如何一键还原,血色浪漫小说,机顶盒影音分配器
django 分页出现此错误:
UnorderedObjectListWarning: Pagination may yield inconsistent results with an unordered object_list: <class 'monitor.models.HostBind'> QuerySet. allow_empty_first_page=allow_empty_first_page, **kwargs)
原因为:
view代码中没有进行排序指定,
class MonitorListView(PaginateListView): model = Monitors template_name = 'monitors_list.html' context_object_name = 'monitor_list' page_kwarg = 'page' ordering = 'name' ##加入ordering排序
或者使用
class MonitorListView(PaginateListView): queryset = Monitors.objects.all().order_by('name') template_name = 'monitors_list.html' context_object_name = 'monitor_list' page_kwarg = 'page'
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
python求numpy中array按列非零元素的平均值案例
网友评论