summaryrefslogtreecommitdiff
path: root/django/forms
diff options
context:
space:
mode:
Diffstat (limited to 'django/forms')
-rw-r--r--django/forms/forms.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/django/forms/forms.py b/django/forms/forms.py
index da30a6220a..97a344e9fc 100644
--- a/django/forms/forms.py
+++ b/django/forms/forms.py
@@ -334,6 +334,15 @@ class BaseForm(object):
if field in self.cleaned_data:
del self.cleaned_data[field]
+ def has_error(self, field, code=None):
+ if code is None:
+ return field in self.errors
+ if field in self.errors:
+ for error in self.errors.as_data()[field]:
+ if error.code == code:
+ return True
+ return False
+
def full_clean(self):
"""
Cleans all of self.data and populates self._errors and