Fixed #35988 -- Made BaseForm.full_clean() pass renderer to ErrorDict.

This commit is contained in:
Adam Johnson
2024-12-09 11:17:25 +00:00
committed by Sarah Boyce
parent 1860a1afc9
commit 02628c051c
2 changed files with 17 additions and 1 deletions

View File

@@ -5313,6 +5313,22 @@ class OverrideTests(SimpleTestCase):
"required></p>",
)
def test_custom_renderer_error_dict(self):
class CustomRenderer(DjangoTemplates):
def render(self, template_name, context, request=None):
if template_name == "django/forms/errors/dict/default.html":
return "<strong>So many errors!</strong>"
return super().render(template_name, context, request)
form = Form({}, renderer=CustomRenderer())
form.full_clean()
form.add_error(None, "Test error")
self.assertHTMLEqual(
form.errors.render(),
"<strong>So many errors!</strong>",
)
def test_cyclic_context_boundfield_render(self):
class FirstNameForm(Form):
first_name = CharField()