Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Rectified bugs that were accidentally committed in r14997. Thanks for…

… the heads-up, Alex Gaynor.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@15011 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit af5ad1116cacda13f48403c5c13af55d94b36a90 1 parent 745c255
@jezdez jezdez authored
View
5 django/contrib/admin/options.py
@@ -422,6 +422,9 @@ def get_formsets(self, request, obj=None):
for inline in self.inline_instances:
yield inline.get_formset(request, obj)
+ def get_paginator(self, request, queryset, per_page, orphans=0, allow_empty_first_page=True):
+ return self.paginator(queryset, per_page, orphans, allow_empty_first_page)
+
def log_addition(self, request, object):
"""
Log that an object has been successfully added.
@@ -979,7 +982,7 @@ def changelist_view(self, request, extra_context=None):
try:
cl = ChangeList(request, self.model, list_display, self.list_display_links,
self.list_filter, self.date_hierarchy, self.search_fields,
- self.list_select_related, self.list_per_page, self.list_editable, self.paginator, self)
+ self.list_select_related, self.list_per_page, self.list_editable, self)
except IncorrectLookupParameters:
# Wacky lookup parameters were given, so redirect to the main
# changelist page, without parameters, and pass an 'invalid=1'
View
8 django/contrib/admin/views/main.py
@@ -26,7 +26,7 @@
EMPTY_CHANGELIST_VALUE = '(None)'
class ChangeList(object):
- def __init__(self, request, model, list_display, list_display_links, list_filter, date_hierarchy, search_fields, list_select_related, list_per_page, list_editable, paginator, model_admin):
+ def __init__(self, request, model, list_display, list_display_links, list_filter, date_hierarchy, search_fields, list_select_related, list_per_page, list_editable, model_admin):
self.model = model
self.opts = model._meta
self.lookup_opts = self.opts
@@ -40,7 +40,6 @@ def __init__(self, request, model, list_display, list_display_links, list_filter
self.list_per_page = list_per_page
self.list_editable = list_editable
self.model_admin = model_admin
- self.paginator = paginator
# Get search parameters from the query string.
try:
@@ -95,7 +94,7 @@ def get_query_string(self, new_params=None, remove=None):
return '?%s' % urlencode(p)
def get_results(self, request):
- paginator = self.get_paginator(self.query_set, self.list_per_page)
+ paginator = self.model_admin.get_paginator(request, self.query_set, self.list_per_page)
# Get the number of objects, with admin filters applied.
result_count = paginator.count
@@ -245,6 +244,3 @@ def construct_search(field_name):
def url_for_result(self, result):
return "%s/" % quote(getattr(result, self.pk_attname))
-
- def get_paginator(self, queryset, per_page, orphans=0, allow_empty_first_page=True):
- return self.paginator(queryset, per_page, orphans, allow_empty_first_page)
View
2  docs/ref/contrib/admin/index.txt
@@ -524,7 +524,7 @@ subclass::
:class:`django.core.paginator.Paginator` is used. If the custom paginator
class doesn't have the same constructor interface as
:class:`django.core.paginator.Paginator`, you will also need to
- provide an implementation for :meth:`MultipleObjectMixin.get_paginator`.
+ provide an implementation for :meth:`ModelAdmin.get_paginator`.
.. attribute:: ModelAdmin.prepopulated_fields
View
20 tests/regressiontests/admin_changelist/tests.py
@@ -17,8 +17,7 @@ def test_select_related_preserved(self):
m = ChildAdmin(Child, admin.site)
cl = ChangeList(MockRequest(), Child, m.list_display, m.list_display_links,
m.list_filter, m.date_hierarchy, m.search_fields,
- m.list_select_related, m.list_per_page, m.list_editable,
- m.paginator, m)
+ m.list_select_related, m.list_per_page, m.list_editable, m)
self.assertEqual(cl.query_set.query.select_related, {'parent': {'name': {}}})
def test_result_list_html(self):
@@ -32,8 +31,7 @@ def test_result_list_html(self):
m = ChildAdmin(Child, admin.site)
cl = ChangeList(request, Child, m.list_display, m.list_display_links,
m.list_filter, m.date_hierarchy, m.search_fields,
- m.list_select_related, m.list_per_page, m.list_editable,
- m.paginator, m)
+ m.list_select_related, m.list_per_page, m.list_editable, m)
cl.formset = None
template = Template('{% load admin_list %}{% spaceless %}{% result_list cl %}{% endspaceless %}')
context = Context({'cl': cl})
@@ -62,8 +60,7 @@ def test_result_list_editable_html(self):
m.list_editable = ['name']
cl = ChangeList(request, Child, m.list_display, m.list_display_links,
m.list_filter, m.date_hierarchy, m.search_fields,
- m.list_select_related, m.list_per_page, m.list_editable,
- m.paginator, m)
+ m.list_select_related, m.list_per_page, m.list_editable, m)
FormSet = m.get_changelist_formset(request)
cl.formset = FormSet(queryset=cl.result_list)
template = Template('{% load admin_list %}{% spaceless %}{% result_list cl %}{% endspaceless %}')
@@ -97,8 +94,7 @@ def test_result_list_editable(self):
self.assertRaises(IncorrectLookupParameters, lambda: \
ChangeList(request, Child, m.list_display, m.list_display_links,
m.list_filter, m.date_hierarchy, m.search_fields,
- m.list_select_related, m.list_per_page, m.list_editable,
- m.paginator, m))
+ m.list_select_related, m.list_per_page, m.list_editable, m))
def test_custom_paginator(self):
new_parent = Parent.objects.create(name='parent')
@@ -114,8 +110,7 @@ def test_custom_paginator(self):
cl = ChangeList(request, Child, m.list_display, m.list_display_links,
m.list_filter, m.date_hierarchy, m.search_fields,
- m.list_select_related, m.list_per_page, m.list_editable,
- m.paginator, m)
+ m.list_select_related, m.list_per_page, m.list_editable, m)
cl.get_results(request)
self.assertIsInstance(cl.paginator, CustomPaginator)
@@ -133,8 +128,5 @@ class MockRequest(object):
class CustomPaginator(Paginator):
def __init__(self, queryset, page_size, orphans=0, allow_empty_first_page=True):
- super(CustomPaginator, self).__init__(
- queryset,
- 5,
- orphans=2,
+ super(CustomPaginator, self).__init__(queryset, 5, orphans=2,
allow_empty_first_page=allow_empty_first_page)
Please sign in to comment.
Something went wrong with that request. Please try again.