django pagenation - WBowam/wbowam.github.com GitHub Wiki
Date: 2014-07-07
Title: django 分页
Tags: Django
Category: It
我个人使用gmail的邮件服务器,不过经常会被墙,因此下面讲解使用qq邮箱服务器。
- 首先看看django-pagination
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',
)
{% load pagination_tags %}
{% autopaginate articles_list 9 %}
<ul>
{% for item in articles_list %}
<li>
<span><a href="#" class="icon-thumbs-up"></a><a href="#" class=" icon-thumbs-down"></a></span>
<div class="list-title"><a href="#">{{ item.title | slice:"15" }}</a></div>
<img class="thumbnail" src="/media/{{ item.title_image }}"><p>{{ item.title_image }}
{{ item.summary | slice:"150"}}</p>
<div class="circle"><div></div><div></div><div></div></div>
</li>
{% endfor %}
{% paginate %}
</ul>
- 直接入侵式修改(强烈不推荐)
- 把pagination.html复制到本地template目录,然后再翻译
pagination.html在(环境目录)/lib/sitepackages/pagination/templates/paginaion.html