1

I'm using django-pagination https://pypi.python.org/pypi/django-pagination 1.0.7 package with Django 1.6. I have observed that my object_list are getting paginated properly when I does work fine ONLY when I do not use extends tag {% extends "base.html" %}

Is django-pagination broken with latest Django or I'm missing something in configuration?

Project name: testing

settings.py

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'testing',
    'pagination',
)

MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'pagination.middleware.PaginationMiddleware',
)

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',
    'django.contrib.messages.context_processors.messages',
)

urls.py

from django.conf.urls import patterns, include, url

from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
    url(r'^$', 'testing.views.home', name='home'),
    url(r'^admin/', include(admin.site.urls)),
)

views.py

from django.shortcuts import render

def home(request):
    return render(request, 'home.html', {
        'numbers': range(100),
        })

base.html

<h1>Hello World</h1>
{% block content%}
{% endblock %}

home.html

{% comment %}
{% extends "base.html" %}
{% endcomment%}

{% load pagination_tags %}
{% autopaginate numbers 2 %}

{% block content %}
{% paginate %}
<ul>
{% for i in numbers %}
  <li>{{ i }}</li>
{% endfor %}
</ul>
{% endblock %}

I do see proper pagination in this case on

http://127.0.0.1:1234 

but if I extends home.html from base.html by then pagination does not work.

Vijayendra Bapte
  • 1,378
  • 3
  • 14
  • 23

0 Answers0