在使用 django 实现分页问题,采用的是class-based views.
实例代码如下:
class IndexView(generic.ListView):
template_name = 'blog/index.html'
model = Article
paginate_by = 20
但是每当加入paginate_by,就会出错,浏览器错误信息为:
EmptyPage at /blog/
That page number is less than 1
Request Method: GET
Request URL: http://localhost:8000/blog/
Django Version: 1.9.5
Exception Type: EmptyPage
Exception Value:
That page number is less than 1
Exception Location: /home/hujianxin/.pyenv/versions/django-web/lib/python3.5/site-packages/django/core/paginator.py in validate_number, line 38
Python Executable: /home/hujianxin/.pyenv/versions/django-web/bin/python
Python Version: 3.5.1
Python Path:
['/home/hujianxin/Programming/personal-site',
'/home/hujianxin/Dropbox/Programming/Spark/spark-1.6.1-bin-hadoop2.6/python',
'/home/hujianxin/Programming/personal-site',
'/home/hujianxin/.pyenv/versions/django-web/lib/python35.zip',
'/home/hujianxin/.pyenv/versions/django-web/lib/python3.5',
'/home/hujianxin/.pyenv/versions/django-web/lib/python3.5/plat-linux',
'/home/hujianxin/.pyenv/versions/django-web/lib/python3.5/lib-dynload',
'/home/hujianxin/.pyenv/versions/anaconda3-2.4.1/envs/django-web/lib/python3.5/site-packages/setuptools-20.7.0-py3.5.egg',
'/home/hujianxin/.pyenv/versions/django-web/lib/python3.5/site-packages']
Server time: Sun, 22 May 2016 05:13:56 +0000
还请有经验的大大帮忙看一下。