diff --git a/django/views/generic/list.py b/django/views/generic/list.py
index d01bacc..ef90d75 100644
a
|
b
|
class MultipleObjectMixin(object):
|
77 | 77 | """ |
78 | 78 | Get the context for this view. |
79 | 79 | """ |
80 | | queryset = kwargs.get('object_list') |
| 80 | queryset = kwargs.pop('object_list') |
81 | 81 | page_size = self.get_paginate_by(queryset) |
82 | 82 | if page_size: |
83 | 83 | paginator, page, queryset, is_paginated = self.paginate_queryset(queryset, page_size) |
diff --git a/tests/regressiontests/generic_views/list.py b/tests/regressiontests/generic_views/list.py
index 5d62aa8..8f6af74 100644
a
|
b
|
class ListViewTests(TestCase):
|
19 | 19 | self.assertEqual(res.status_code, 200) |
20 | 20 | self.assertTemplateUsed(res, 'generic_views/author_list.html') |
21 | 21 | self.assertEqual(list(res.context['object_list']), list(Author.objects.all())) |
22 | | self.assertEqual(list(res.context['authors']), list(Author.objects.all())) |
23 | | self.assertEqual(res.context['paginator'], None) |
24 | | self.assertEqual(res.context['page_obj'], None) |
25 | | self.assertEqual(res.context['is_paginated'], False) |
| 22 | self.assertIs(res.context['authors'], res.context['object_list']) |
| 23 | self.assertIsNone(res.context['paginator']) |
| 24 | self.assertIsNone(res.context['page_obj']) |
| 25 | self.assertFalse(res.context['is_paginated']) |
26 | 26 | |
27 | 27 | def test_paginated_queryset(self): |
28 | 28 | self._make_authors(100) |
29 | 29 | res = self.client.get('/list/authors/paginated/') |
30 | 30 | self.assertEqual(res.status_code, 200) |
31 | 31 | self.assertTemplateUsed(res, 'generic_views/author_list.html') |
32 | | self.assertEqual(len(res.context['authors']), 30) |
33 | | self.assertEqual(res.context['is_paginated'], True) |
| 32 | self.assertEqual(len(res.context['object_list']), 30) |
| 33 | self.assertIs(res.context['authors'], res.context['object_list']) |
| 34 | self.assertTrue(res.context['is_paginated']) |
34 | 35 | self.assertEqual(res.context['page_obj'].number, 1) |
35 | 36 | self.assertEqual(res.context['paginator'].num_pages, 4) |
36 | 37 | self.assertEqual(res.context['authors'][0].name, 'Author 00') |
… |
… |
class ListViewTests(TestCase):
|
41 | 42 | self.assertEqual(res.status_code, 200) |
42 | 43 | self.assertTemplateUsed(res, 'generic_views/author_list.html') |
43 | 44 | self.assertEqual(list(res.context['object_list']), list(Author.objects.all())) |
44 | | self.assertEqual(list(res.context['authors']), list(Author.objects.all())) |
45 | | self.assertEqual(res.context['paginator'], None) |
46 | | self.assertEqual(res.context['page_obj'], None) |
47 | | self.assertEqual(res.context['is_paginated'], False) |
| 45 | self.assertIs(res.context['authors'], res.context['object_list']) |
| 46 | self.assertIsNone(res.context['paginator']) |
| 47 | self.assertIsNone(res.context['page_obj']) |
| 48 | self.assertFalse(res.context['is_paginated']) |
48 | 49 | |
49 | 50 | def test_paginated_get_page_by_query_string(self): |
50 | 51 | self._make_authors(100) |
51 | 52 | res = self.client.get('/list/authors/paginated/', {'page': '2'}) |
52 | 53 | self.assertEqual(res.status_code, 200) |
53 | 54 | self.assertTemplateUsed(res, 'generic_views/author_list.html') |
54 | | self.assertEqual(len(res.context['authors']), 30) |
| 55 | self.assertEqual(len(res.context['object_list']), 30) |
| 56 | self.assertIs(res.context['authors'], res.context['object_list']) |
55 | 57 | self.assertEqual(res.context['authors'][0].name, 'Author 30') |
56 | 58 | self.assertEqual(res.context['page_obj'].number, 2) |
57 | 59 | |
… |
… |
class ListViewTests(TestCase):
|
59 | 61 | self._make_authors(100) |
60 | 62 | res = self.client.get('/list/authors/paginated/', {'page': 'last'}) |
61 | 63 | self.assertEqual(res.status_code, 200) |
62 | | self.assertEqual(len(res.context['authors']), 10) |
| 64 | self.assertEqual(len(res.context['object_list']), 10) |
| 65 | self.assertIs(res.context['authors'], res.context['object_list']) |
63 | 66 | self.assertEqual(res.context['authors'][0].name, 'Author 90') |
64 | 67 | self.assertEqual(res.context['page_obj'].number, 4) |
65 | 68 | |
… |
… |
class ListViewTests(TestCase):
|
68 | 71 | res = self.client.get('/list/authors/paginated/3/') |
69 | 72 | self.assertEqual(res.status_code, 200) |
70 | 73 | self.assertTemplateUsed(res, 'generic_views/author_list.html') |
71 | | self.assertEqual(len(res.context['authors']), 30) |
| 74 | self.assertEqual(len(res.context['object_list']), 30) |
| 75 | self.assertIs(res.context['authors'], res.context['object_list']) |
72 | 76 | self.assertEqual(res.context['authors'][0].name, 'Author 60') |
73 | 77 | self.assertEqual(res.context['page_obj'].number, 3) |
74 | 78 | |
… |
… |
class ListViewTests(TestCase):
|
93 | 97 | res = self.client.get('/list/authors/template_name/') |
94 | 98 | self.assertEqual(res.status_code, 200) |
95 | 99 | self.assertEqual(list(res.context['object_list']), list(Author.objects.all())) |
96 | | self.assertEqual(list(res.context['authors']), list(Author.objects.all())) |
| 100 | self.assertIs(res.context['authors'], res.context['object_list']) |
97 | 101 | self.assertTemplateUsed(res, 'generic_views/list.html') |
98 | 102 | |
99 | 103 | def test_template_name_suffix(self): |
100 | 104 | res = self.client.get('/list/authors/template_name_suffix/') |
101 | 105 | self.assertEqual(res.status_code, 200) |
102 | 106 | self.assertEqual(list(res.context['object_list']), list(Author.objects.all())) |
103 | | self.assertEqual(list(res.context['authors']), list(Author.objects.all())) |
| 107 | self.assertIs(res.context['authors'], res.context['object_list']) |
104 | 108 | self.assertTemplateUsed(res, 'generic_views/author_objects.html') |
105 | 109 | |
106 | 110 | def test_context_object_name(self): |
107 | 111 | res = self.client.get('/list/authors/context_object_name/') |
108 | 112 | self.assertEqual(res.status_code, 200) |
109 | 113 | self.assertEqual(list(res.context['object_list']), list(Author.objects.all())) |
110 | | self.assertEqual(list(res.context['author_list']), list(Author.objects.all())) |
111 | | self.assertFalse('authors' in res.context) |
| 114 | self.assertNotIn('authors', res.context) |
| 115 | self.assertIs(res.context['author_list'], res.context['object_list']) |
112 | 116 | self.assertTemplateUsed(res, 'generic_views/author_list.html') |
113 | 117 | |
114 | 118 | def test_duplicate_context_object_name(self): |
115 | 119 | res = self.client.get('/list/authors/dupe_context_object_name/') |
116 | 120 | self.assertEqual(res.status_code, 200) |
117 | 121 | self.assertEqual(list(res.context['object_list']), list(Author.objects.all())) |
118 | | self.assertFalse('author_list' in res.context) |
119 | | self.assertFalse('authors' in res.context) |
| 122 | self.assertNotIn('authors', res.context) |
| 123 | self.assertNotIn('author_list', res.context) |
120 | 124 | self.assertTemplateUsed(res, 'generic_views/author_list.html') |
121 | 125 | |
122 | 126 | def test_missing_items(self): |