2012-06-07 116 views
1

django-pagination的文檔已過期1.4。跟蹤他們時,我沒有收到錯誤,但分頁不起作用。分頁頁面計數器加載,但沒有分頁。以下是我有:Django的Django分頁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 %} 

感謝您的幫助。

+0

你認爲什麼是代碼? –

回答

0

有幾個項目可能應該在模板中進行更正。嘗試以下一種或兩種方法:

A.解決方案可能有效,但可能不是您想要的。

<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> 
    {% endfor %} 
    {% paginate %} 
    </tr> 
</table> 
</div> 

B.解決方法 - 如果A不起作用,請嘗試此操作。

<div class="photo-gallery"> 

<table border="0" cellspacing="0" cellpadding="0"> 
    {% autopaginate object.public 10 %} 
    <tr> 
    {% 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> 
    {% endfor %} 
    </tr> 
    {% paginate %} 
</table>  
</div> 
1

你的問題到底是什麼,我不確定你在問什麼。

我認爲django-pagination沒有維持兩年左右。我記得試過了,它不工作,所以我切換到django-endless-pagination,並沒有任何問題。你可能想考慮檢查一下/試一試。