Paginate Class-based View in Django

核能气质少年 提交于 2019-12-05 04:46:24

Just add paginate_by = 20 to you view class.

class IssuesByTitleView(ListView):
    context_object_name = "issue_list"
    paginate_by = 20

    #More stuff here..

Just like Evan Porter has commented, you can make use of the page_obj context variable to access number, paginatior.num_pages, has_next, has_previous. This is what just saved me from the KeyError['page'] after upgrading from Django 1.4.1 to 1.7, object_list to ListView

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!