From 045e72f2dd4a8fc93142f2fae3dbf72ea5a87bc5 Mon Sep 17 00:00:00 2001 From: Tim Heap Date: Thu, 16 Jul 2015 18:42:04 +1000 Subject: [PATCH] Update styleguide to use `{% paginate %}` --- .../templates/wagtailstyleguide/base.html | 2 +- wagtail/contrib/wagtailstyleguide/views.py | 15 ++++----------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/wagtail/contrib/wagtailstyleguide/templates/wagtailstyleguide/base.html b/wagtail/contrib/wagtailstyleguide/templates/wagtailstyleguide/base.html index e23b8b281e..c568fe5bd7 100644 --- a/wagtail/contrib/wagtailstyleguide/templates/wagtailstyleguide/base.html +++ b/wagtail/contrib/wagtailstyleguide/templates/wagtailstyleguide/base.html @@ -226,7 +226,7 @@

Pagination

- {% include "wagtailadmin/shared/pagination_nav.html" with items=fake_pagination linkurl="wagtailadmin_explore" %} + {% paginate example_page %}
diff --git a/wagtail/contrib/wagtailstyleguide/views.py b/wagtail/contrib/wagtailstyleguide/views.py index 05dd1c999e..7946e12304 100644 --- a/wagtail/contrib/wagtailstyleguide/views.py +++ b/wagtail/contrib/wagtailstyleguide/views.py @@ -1,6 +1,7 @@ from django import forms from django.shortcuts import render from django.utils.translation import ugettext as _ +from django.core.paginator import Paginator from wagtail.wagtailadmin import messages from wagtail.wagtailadmin.forms import SearchForm @@ -56,19 +57,11 @@ def index(request): messages.button('', _('Edit')) ]) - fake_pagination = { - 'number': 1, - 'previous_page_number': 1, - 'next_page_number': 2, - 'has_previous': True, - 'has_next': True, - 'paginator': { - 'num_pages': 10, - }, - } + paginator = Paginator(list(range(100)), 10) + page = paginator.page(2) return render(request, 'wagtailstyleguide/base.html', { 'search_form': form, 'example_form': example_form, - 'fake_pagination': fake_pagination, + 'example_page': page, })