Ticket #14312: fix14312-1.patch

File fix14312-1.patch, 2.0 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..1306cd4 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                result_list = self.root_query_set.none()
    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..f70fa63 100644
    a b class ChangeListTests(TransactionTestCase):  
    7171        self.failIf('<td>%s</td>' % editable_name_field == -1,
    7272            'Failed to find "name" list_editable field in: %s' % table_output)
    7373
     74    def test_result_list_editable(self):
     75        """
     76        Regression test for #14312: list_editable with pagination
     77        """
     78
     79        new_parent = Parent.objects.create(name='parent')
     80        for i in range(200):
     81            new_child = Child.objects.create(name='name %s' % i, parent=new_parent)
     82        request = MockRequest()
     83        request.GET['p'] = -1 # Anything outside range
     84        m = ChildAdmin(Child, admin.site)
     85
     86        # Test with list_editable fields
     87        m.list_display = ['id', 'name', 'parent']
     88        m.list_display_links = ['id']
     89        m.list_editable = ['name']
     90        cl = ChangeList(request, Child, m.list_display, m.list_display_links,
     91                m.list_filter, m.date_hierarchy, m.search_fields,
     92                m.list_select_related, m.list_per_page, m.list_editable, m)
     93        FormSet = m.get_changelist_formset(request)
     94        cl.formset = FormSet(queryset=cl.result_list)
     95
     96
    7497class ChildAdmin(admin.ModelAdmin):
    7598    list_display = ['name', 'parent']
    7699    def queryset(self, request):
Back to Top