Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
Jannis Leidel authored
5  django/contrib/admin/options.py
@@ -422,6 +422,9 @@ def get_formsets(self, request, obj=None):
422 422
         for inline in self.inline_instances:
423 423
             yield inline.get_formset(request, obj)
424 424
 
  425
+    def get_paginator(self, request, queryset, per_page, orphans=0, allow_empty_first_page=True):
  426
+        return self.paginator(queryset, per_page, orphans, allow_empty_first_page)
  427
+
425 428
     def log_addition(self, request, object):
426 429
         """
427 430
         Log that an object has been successfully added.
@@ -979,7 +982,7 @@ def changelist_view(self, request, extra_context=None):
979 982
         try:
980 983
             cl = ChangeList(request, self.model, list_display, self.list_display_links,
981 984
                 self.list_filter, self.date_hierarchy, self.search_fields,
982  
-                self.list_select_related, self.list_per_page, self.list_editable, self.paginator, self)
  985
+                self.list_select_related, self.list_per_page, self.list_editable, self)
983 986
         except IncorrectLookupParameters:
984 987
             # Wacky lookup parameters were given, so redirect to the main
985 988
             # changelist page, without parameters, and pass an 'invalid=1'
8  django/contrib/admin/views/main.py
@@ -26,7 +26,7 @@
26 26
 EMPTY_CHANGELIST_VALUE = '(None)'
27 27
 
28 28
 class ChangeList(object):
29  
-    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):
  29
+    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):
30 30
         self.model = model
31 31
         self.opts = model._meta
32 32
         self.lookup_opts = self.opts
@@ -40,7 +40,6 @@ def __init__(self, request, model, list_display, list_display_links, list_filter
40 40
         self.list_per_page = list_per_page
41 41
         self.list_editable = list_editable
42 42
         self.model_admin = model_admin
43  
-        self.paginator = paginator
44 43
 
45 44
         # Get search parameters from the query string.
46 45
         try:
@@ -95,7 +94,7 @@ def get_query_string(self, new_params=None, remove=None):
95 94
         return '?%s' % urlencode(p)
96 95
 
97 96
     def get_results(self, request):
98  
-        paginator = self.get_paginator(self.query_set, self.list_per_page)
  97
+        paginator = self.model_admin.get_paginator(request, self.query_set, self.list_per_page)
99 98
         # Get the number of objects, with admin filters applied.
100 99
         result_count = paginator.count
101 100
 
@@ -245,6 +244,3 @@ def construct_search(field_name):
245 244
 
246 245
     def url_for_result(self, result):
247 246
         return "%s/" % quote(getattr(result, self.pk_attname))
248  
-
249  
-    def get_paginator(self, queryset, per_page, orphans=0, allow_empty_first_page=True):
250  
-        return self.paginator(queryset, per_page, orphans, allow_empty_first_page)
2  docs/ref/contrib/admin/index.txt
@@ -524,7 +524,7 @@ subclass::
524 524
     :class:`django.core.paginator.Paginator` is used. If the custom paginator
525 525
     class doesn't have the same constructor interface as
526 526
     :class:`django.core.paginator.Paginator`, you will also need to
527  
-    provide an implementation for :meth:`MultipleObjectMixin.get_paginator`.
  527
+    provide an implementation for :meth:`ModelAdmin.get_paginator`.
528 528
 
529 529
 .. attribute:: ModelAdmin.prepopulated_fields
530 530
 
20  tests/regressiontests/admin_changelist/tests.py
@@ -17,8 +17,7 @@ def test_select_related_preserved(self):
17 17
         m = ChildAdmin(Child, admin.site)
18 18
         cl = ChangeList(MockRequest(), Child, m.list_display, m.list_display_links,
19 19
                 m.list_filter, m.date_hierarchy, m.search_fields,
20  
-                m.list_select_related, m.list_per_page, m.list_editable,
21  
-                m.paginator, m)
  20
+                m.list_select_related, m.list_per_page, m.list_editable, m)
22 21
         self.assertEqual(cl.query_set.query.select_related, {'parent': {'name': {}}})
23 22
 
24 23
     def test_result_list_html(self):
@@ -32,8 +31,7 @@ def test_result_list_html(self):
32 31
         m = ChildAdmin(Child, admin.site)
33 32
         cl = ChangeList(request, Child, m.list_display, m.list_display_links,
34 33
                 m.list_filter, m.date_hierarchy, m.search_fields,
35  
-                m.list_select_related, m.list_per_page, m.list_editable,
36  
-                m.paginator, m)
  34
+                m.list_select_related, m.list_per_page, m.list_editable, m)
37 35
         cl.formset = None
38 36
         template = Template('{% load admin_list %}{% spaceless %}{% result_list cl %}{% endspaceless %}')
39 37
         context = Context({'cl': cl})
@@ -62,8 +60,7 @@ def test_result_list_editable_html(self):
62 60
         m.list_editable = ['name']
63 61
         cl = ChangeList(request, Child, m.list_display, m.list_display_links,
64 62
                 m.list_filter, m.date_hierarchy, m.search_fields,
65  
-                m.list_select_related, m.list_per_page, m.list_editable,
66  
-                m.paginator, m)
  63
+                m.list_select_related, m.list_per_page, m.list_editable, m)
67 64
         FormSet = m.get_changelist_formset(request)
68 65
         cl.formset = FormSet(queryset=cl.result_list)
69 66
         template = Template('{% load admin_list %}{% spaceless %}{% result_list cl %}{% endspaceless %}')
@@ -97,8 +94,7 @@ def test_result_list_editable(self):
97 94
         self.assertRaises(IncorrectLookupParameters, lambda: \
98 95
             ChangeList(request, Child, m.list_display, m.list_display_links,
99 96
                     m.list_filter, m.date_hierarchy, m.search_fields,
100  
-                    m.list_select_related, m.list_per_page, m.list_editable,
101  
-                    m.paginator, m))
  97
+                    m.list_select_related, m.list_per_page, m.list_editable, m))
102 98
 
103 99
     def test_custom_paginator(self):
104 100
         new_parent = Parent.objects.create(name='parent')
@@ -114,8 +110,7 @@ def test_custom_paginator(self):
114 110
 
115 111
         cl = ChangeList(request, Child, m.list_display, m.list_display_links,
116 112
                 m.list_filter, m.date_hierarchy, m.search_fields,
117  
-                m.list_select_related, m.list_per_page, m.list_editable,
118  
-                m.paginator, m)
  113
+                m.list_select_related, m.list_per_page, m.list_editable, m)
119 114
 
120 115
         cl.get_results(request)
121 116
         self.assertIsInstance(cl.paginator, CustomPaginator)
@@ -133,8 +128,5 @@ class MockRequest(object):
133 128
 
134 129
 class CustomPaginator(Paginator):
135 130
     def __init__(self, queryset, page_size, orphans=0, allow_empty_first_page=True):
136  
-        super(CustomPaginator, self).__init__(
137  
-            queryset,
138  
-            5,
139  
-            orphans=2,
  131
+        super(CustomPaginator, self).__init__(queryset, 5, orphans=2,
140 132
             allow_empty_first_page=allow_empty_first_page)

0 notes on commit af5ad11

Please sign in to comment.
Something went wrong with that request. Please try again.