Ticket #14312: fix14312-2.patch

File fix14312-2.patch, 2.2 KB (added by Matthias Kestenholz, 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):  
    116116            try:
    117117                result_list = paginator.page(self.page_num+1).object_list
    118118            except InvalidPage:
    119                 result_list = ()
     119                raise IncorrectLookupParameters
    120120
    121121        self.result_count = result_count
    122122        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  
    11from django.contrib import admin
     2from django.contrib.admin.options import IncorrectLookupParameters
    23from django.contrib.admin.views.main import ChangeList
    34from django.template import Context, Template
    45from django.test import TransactionTestCase
    class ChangeListTests(TransactionTestCase):  
    7172        self.failIf('<td>%s</td>' % editable_name_field == -1,
    7273            'Failed to find "name" list_editable field in: %s' % table_output)
    7374
     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
    7497class ChildAdmin(admin.ModelAdmin):
    7598    list_display = ['name', 'parent']
    7699    def queryset(self, request):
Back to Top