本文主要是介绍django ListView指定分页条数,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
class DeviceListView(ListView):model = Device # 指定类paginate_by = 8# 在类中 重写如下方法,增加在requst中获取分页的判断def get_paginate_by(self, queryset):"""Get the number of items to paginate by, or ``None`` for no pagination."""paginate_by = self.request.GET.get('paginate_by')if paginate_by:return paginate_byreturn self.paginate_by
这篇关于django ListView指定分页条数的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!