Ticket #14312: fix14312-2.patch
File fix14312-2.patch, 2.2 KB (added by , 14 years ago) |
---|
-
django/contrib/admin/views/main.py
diff --git a/django/contrib/admin/views/main.py b/django/contrib/admin/views/main.py index 8c09c10..55e9d6f 100644
a b class ChangeList(object): 116 116 try: 117 117 result_list = paginator.page(self.page_num+1).object_list 118 118 except InvalidPage: 119 r esult_list = ()119 raise IncorrectLookupParameters 120 120 121 121 self.result_count = result_count 122 122 self.full_result_count = full_result_count -
tests/regressiontests/admin_changelist/tests.py
diff --git a/tests/regressiontests/admin_changelist/tests.py b/tests/regressiontests/admin_changelist/tests.py index c8ad1ce..7d9b94e 100644
a b 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 … … class ChangeListTests(TransactionTestCase): 71 72 self.failIf('<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):