Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #14312 -- Raising an ``IncorrectLookupParameters`` if the page …

…number given to an admin change list exceeds the number of the last page. Thanks, mk.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@14889 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit d8165ce1566771960cf33e414c1a6e643fd46dea 1 parent a03a8ad
Jannis Leidel authored December 12, 2010
2  django/contrib/admin/views/main.py
@@ -117,7 +117,7 @@ def get_results(self, request):
117 117
             try:
118 118
                 result_list = paginator.page(self.page_num+1).object_list
119 119
             except InvalidPage:
120  
-                result_list = ()
  120
+                raise IncorrectLookupParameters
121 121
 
122 122
         self.result_count = result_count
123 123
         self.full_result_count = full_result_count
23  tests/regressiontests/admin_changelist/tests.py
... ...
@@ -1,4 +1,5 @@
1 1
 from django.contrib import admin
  2
+from django.contrib.admin.options import IncorrectLookupParameters
2 3
 from django.contrib.admin.views.main import ChangeList
3 4
 from django.template import Context, Template
4 5
 from django.test import TransactionTestCase
@@ -71,6 +72,28 @@ def test_result_list_editable_html(self):
71 72
         self.assertFalse('<td>%s</td>' % editable_name_field == -1,
72 73
             'Failed to find "name" list_editable field in: %s' % table_output)
73 74
 
  75
+    def test_result_list_editable(self):
  76
+        """
  77
+        Regression test for #14312: list_editable with pagination
  78
+        """
  79
+
  80
+        new_parent = Parent.objects.create(name='parent')
  81
+        for i in range(200):
  82
+            new_child = Child.objects.create(name='name %s' % i, parent=new_parent)
  83
+        request = MockRequest()
  84
+        request.GET['p'] = -1 # Anything outside range
  85
+        m = ChildAdmin(Child, admin.site)
  86
+
  87
+        # Test with list_editable fields
  88
+        m.list_display = ['id', 'name', 'parent']
  89
+        m.list_display_links = ['id']
  90
+        m.list_editable = ['name']
  91
+        self.assertRaises(IncorrectLookupParameters, lambda: \
  92
+            ChangeList(request, Child, m.list_display, m.list_display_links,
  93
+                    m.list_filter, m.date_hierarchy, m.search_fields,
  94
+                    m.list_select_related, m.list_per_page, m.list_editable, m))
  95
+
  96
+
74 97
 class ChildAdmin(admin.ModelAdmin):
75 98
     list_display = ['name', 'parent']
76 99
     def queryset(self, request):

0 notes on commit d8165ce

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