Skip to content

Instantly share code, notes, and snippets.

@TSKGunGun
Last active October 6, 2021 10:07
Show Gist options
  • Save TSKGunGun/44cff528f3d2b8e56c30c1e0e1b4917a to your computer and use it in GitHub Desktop.
Save TSKGunGun/44cff528f3d2b8e56c30c1e0e1b4917a to your computer and use it in GitHub Desktop.
def errors(self):
"""Return an ErrorDict for the data provided for the form."""
if self._errors is None:
self.full_clean()
return self._errors
def is_valid(self):
"""Return True if the form has no errors, or False otherwise."""
return self.is_bound and not self.errors
def full_clean(self):
"""
Clean all of self.data and populate self._errors and self.cleaned_data.
"""
self._errors = ErrorDict()
if not self.is_bound: # Stop further processing.
return
self.cleaned_data = {}
# If the form is permitted to be empty, and none of the form data has
# changed from the initial data, short circuit any validation.
if self.empty_permitted and not self.has_changed():
return
self._clean_fields()
self._clean_form()
self._post_clean()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment