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:
parent
0fc6d5362b
commit
3ee4c6a27a
@ -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
|
||||
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user