根据django1.5写的paginator分页函数与代码。怎么一直不显示呢?代码如下
根据django1.5写的分页代码
views.py 的分页函数
def listing(request):
msg_list = Msg.objects.all()
paginator = Paginator(msg_list, 6)
page = request.GET.get('page')
try:
msgpages = paginator.page(page)
except PageNotAnInteger:
msgpages = paginator.page(1)
except EmptyPage:
msgpages = paginator.page(paginator.num_pages)
return render_to_response('pagination/list.html', {'msgpages': msgpages})
url(r'^$',
ListView.as_view(
#paginate_by=ITEMS_PER_PAGE,
queryset=Msg.objects.order_by('-id'),
context_object_name='msg_list',
template_name='msg_list_page.html'
)),
{% extends "base.html" %}
{% block title %}留言列表{% endblock %}
{% block content %}
<table class="msglist">
<caption><h2>Django 留言本</h2></caption>
{% include "msg_list.html" %}
</table>
{% include "pagination/list.html" %}
{% endblock %}
{% for msgpage in msgpages %}
{{ msgpage.full_name|upper }}
{% endfor %}
<div class="pagination">
<span class="step-links">
{% if msgpages.has_previous %}
<a href="?page={{ msgpages.previous_page_number }}">previous</a>
{% endif %}
<span class="current">
Page {{ msgpages.number }} of {{ msgpages.paginator.num_pages }}
</span>
{% if msgpages.has_next %}
<a href="?page={{ msgpages.next_page_number }}">next</a>
{% endif %}
</span>
</div>