1
0
mirror of https://github.com/django/django.git synced 2024-12-22 09:05:43 +00:00

Refs #26007 -- Improved the ImproperlyConfigured error message for SingleObjectTemplateResponseMixin.get_template_names().

This commit is contained in:
Andrew Miller 2024-12-15 21:04:29 +00:00 committed by Sarah Boyce
parent 0fc6d5362b
commit 3ee4c6a27a
2 changed files with 8 additions and 3 deletions

View File

@ -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

View File

@ -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()