summaryrefslogtreecommitdiff
path: root/django/forms
diff options
context:
space:
mode:
authorDavid Smith <39445562+smithdc1@users.noreply.github.com>2023-11-20 07:57:03 +0000
committerGitHub <noreply@github.com>2023-11-20 08:57:03 +0100
commitf1697ec7c8fc851baa9c890a605acb67f04210f2 (patch)
tree7a522cce0e67531b90e71749b206c581a3088a1a /django/forms
parentecfea054ee2b8ddfa027459ff8b6aecba05facf7 (diff)
Refs #31026 -- Simplified BaseForm.get_context().
bf.errors returns an ErrorList. Access this directly and avoid creating a new instance in BaseForm.get_context() Calling str() on the ErrorList can also be deferred to when the variable used in the template.
Diffstat (limited to 'django/forms')
-rw-r--r--django/forms/forms.py8
1 files changed, 3 insertions, 5 deletions
diff --git a/django/forms/forms.py b/django/forms/forms.py
index b99ec8248a..5de14d598a 100644
--- a/django/forms/forms.py
+++ b/django/forms/forms.py
@@ -224,18 +224,16 @@ class BaseForm(RenderableFormMixin):
hidden_fields = []
top_errors = self.non_field_errors().copy()
for name, bf in self._bound_items():
- bf_errors = self.error_class(bf.errors, renderer=self.renderer)
if bf.is_hidden:
- if bf_errors:
+ if bf.errors:
top_errors += [
_("(Hidden field %(name)s) %(error)s")
% {"name": name, "error": str(e)}
- for e in bf_errors
+ for e in bf.errors
]
hidden_fields.append(bf)
else:
- errors_str = str(bf_errors)
- fields.append((bf, errors_str))
+ fields.append((bf, bf.errors))
return {
"form": self,
"fields": fields,