diff --git a/django/views/generic/list.py b/django/views/generic/list.py
index ec30c58..946dad6 100644
a
|
b
|
class MultipleObjectMixin(ContextMixin):
|
50 | 50 | try: |
51 | 51 | page = paginator.page(page_number) |
52 | 52 | return (paginator, page, page.object_list, page.has_other_pages()) |
53 | | except InvalidPage: |
54 | | raise Http404(_('Invalid page (%(page_number)s)') % { |
55 | | 'page_number': page_number |
| 53 | except InvalidPage as e: |
| 54 | raise Http404(_('Invalid page (%(page_number)s): %(message)s') % { |
| 55 | 'page_number': page_number, |
| 56 | 'message': e.message, |
56 | 57 | }) |
57 | 58 | |
58 | 59 | def get_paginate_by(self, queryset): |
diff --git a/tests/regressiontests/generic_views/list.py b/tests/regressiontests/generic_views/list.py
index 14dc1d7..6f07480 100644
a
|
b
|
from __future__ import absolute_import
|
2 | 2 | |
3 | 3 | from django.core.exceptions import ImproperlyConfigured |
4 | 4 | from django.test import TestCase |
| 5 | from django.test.utils import override_settings |
5 | 6 | from django.views.generic.base import View |
6 | 7 | |
7 | 8 | from .models import Author, Artist |
… |
… |
class ListViewTests(TestCase):
|
171 | 172 | with self.assertNumQueries(3): |
172 | 173 | self.client.get('/list/authors/notempty/paginated/') |
173 | 174 | |
| 175 | @override_settings(DEBUG=True) |
| 176 | def test_paginated_list_view_returns_useful_message_on_invalid_page(self): |
| 177 | self._make_authors(1) |
| 178 | res = self.client.get('/list/authors/paginated/2/') |
| 179 | self.assertEqual(res.status_code, 404) |
| 180 | self.assertEqual(res.context.get('reason'), "Invalid page (2): That page contains no results") |
| 181 | |
174 | 182 | def _make_authors(self, n): |
175 | 183 | Author.objects.all().delete() |
176 | 184 | for i in range(n): |
177 | 185 | Author.objects.create(name='Author %02i' % i, slug='a%s' % i) |
178 | | |