Question

The docs for django-pagination are out of date for 1.4. When following them, I don't receive errors but the pagination doesn't work. The pagination page counter loads, but there is no pagination. Here is what I have:

settings.py here:

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 here:

{% 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 %}

Thanks for the help.

Était-ce utile?

La solution

There are a couple of items that probably should be corrected in the template. Try one or both of the following:

A. Solution may work, but may not be what you want.

<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. Solution - If A does not work try this.

<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>

Autres conseils

What exactly is your question, I'm not sure what you're asking.

I think django-pagination hasn't been maintained for two years or so. I remember trying it out, and it not working, so I switched to django-endless-pagination and have had no problems. You may want to consider checking it out/giving it a try.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top