1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Merge pull request #467 from tomchristie/page-kwarg

Add 'page_kwarg' attribute to `MultipleObjectMixin`, removing hardcoded "page".
This commit is contained in:
Jannis Leidel
2012-11-17 12:27:01 -08:00
4 changed files with 26 additions and 3 deletions

View File

@@ -17,6 +17,7 @@ class MultipleObjectMixin(ContextMixin):
paginate_by = None
context_object_name = None
paginator_class = Paginator
page_kwarg = 'page'
def get_queryset(self):
"""
@@ -39,7 +40,8 @@ class MultipleObjectMixin(ContextMixin):
Paginate the queryset, if needed.
"""
paginator = self.get_paginator(queryset, page_size, allow_empty_first_page=self.get_allow_empty())
page = self.kwargs.get('page') or self.request.GET.get('page') or 1
page_kwarg = self.page_kwarg
page = self.kwargs.get(page_kwarg) or self.request.GET.get(page_kwarg) or 1
try:
page_number = int(page)
except ValueError: