django-pagination 的文档对于 1.4 来说已经过时了。关注它们时,我没有收到错误,但分页不起作用。分页页面计数器加载,但没有分页。这是我所拥有的:
settings.py 这里:
TEMPLATE_CONTEXT_PROCESSORS = (
"django.contrib.auth.context_processors.auth",
"django.core.context_processors.debug",
"django.core.context_processors.i18n",
"django.core.context_processors.media",
"django.core.context_processors.static",
"django.core.context_processors.tz",
"django.core.context_processors.request",)
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'pagination.middleware.PaginationMiddleware',
)
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'django.contrib.admindocs',
'photologue',
'pagination',
)
gallery_detail.html 这里:
{% extends "photologue/root.html" %}
{% load pagination_tags %}
{% block title %}{{ object.title }}{% endblock %}
{% block content %}
<h1>Gallery {{ object.title }}</h1>
<h2>Originally published {{ object.date_added|date:"l, F jS, Y" }}</h2>
{% if object.description %}<p>{{ object.description }}</p>{% endif %}
<div class="photo-gallery">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
{% autopaginate object.public 10 %}
{% for photo in object.public %}
<td><div class="gallery-photo">
<a href="{{ photo.get_absolute_url }}"><img src="{{ photo.get_thumbnail_url }}" alt="{{ photo.title }}"/></a>
</div></td>
</tr>
</table>
{% endfor %}
{% paginate %}
</div>
<p><a href="{% url pl-gallery-list 1 %}">View all galleries</a></p>
{% endblock %}
谢谢您的帮助。