diff --git a/django/views/generic/list.py b/django/views/generic/list.py index 946dad69f56..e9d57a07023 100644 --- a/django/views/generic/list.py +++ b/django/views/generic/list.py @@ -53,7 +53,7 @@ class MultipleObjectMixin(ContextMixin): except InvalidPage as e: raise Http404(_('Invalid page (%(page_number)s): %(message)s') % { 'page_number': page_number, - 'message': e.message, + 'message': str(e) }) def get_paginate_by(self, queryset): diff --git a/tests/regressiontests/generic_views/list.py b/tests/regressiontests/generic_views/list.py index 6c73138043e..a8ed9e856ba 100644 --- a/tests/regressiontests/generic_views/list.py +++ b/tests/regressiontests/generic_views/list.py @@ -4,6 +4,7 @@ from django.core.exceptions import ImproperlyConfigured from django.test import TestCase from django.test.utils import override_settings from django.views.generic.base import View +from django.utils.encoding import force_str from .models import Author, Artist @@ -179,7 +180,7 @@ class ListViewTests(TestCase): self._make_authors(1) res = self.client.get('/list/authors/paginated/2/') self.assertEqual(res.status_code, 404) - self.assertEqual(res.context.get('reason'), + self.assertEqual(force_str(res.context.get('reason')), "Invalid page (2): That page contains no results") def _make_authors(self, n):