diff --git a/django/views/generic/detail.py b/django/views/generic/detail.py index 05ced1f25d..70e427c59b 100644 --- a/django/views/generic/detail.py +++ b/django/views/generic/detail.py @@ -171,7 +171,11 @@ class SingleObjectTemplateResponseMixin(TemplateResponseMixin): # If we still haven't managed to find any template names, we should # re-raise the ImproperlyConfigured to alert the user. if not names: - raise + raise ImproperlyConfigured( + "SingleObjectTemplateResponseMixin requires a definition " + "of 'template_name', 'template_name_field', or 'model'; " + "or an implementation of 'get_template_names()'." + ) return names diff --git a/tests/generic_views/test_base.py b/tests/generic_views/test_base.py index add485245a..5f3941196b 100644 --- a/tests/generic_views/test_base.py +++ b/tests/generic_views/test_base.py @@ -607,8 +607,9 @@ class SingleObjectTemplateResponseMixinTest(SimpleTestCase): """ view = views.TemplateResponseWithoutTemplate() msg = ( - "TemplateResponseMixin requires either a definition of " - "'template_name' or an implementation of 'get_template_names()'" + "SingleObjectTemplateResponseMixin requires a definition " + "of 'template_name', 'template_name_field', or 'model'; " + "or an implementation of 'get_template_names()'." ) with self.assertRaisesMessage(ImproperlyConfigured, msg): view.get_template_names()