我们从Python开源项目中,提取了以下12个代码示例,用于说明如何使用django.forms.utils.ErrorDict()。
def full_clean(self): """ Cleans all of self.data and populates 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()
def nice_errors(form, non_field_msg='General form errors'): nice_errors = ErrorDict() if isinstance(form, forms.BaseForm): for field, errors in form.errors.items(): if field == NON_FIELD_ERRORS: key = non_field_msg else: key = form.fields[field].label nice_errors[key] = errors return nice_errors
def errors(self): "Returns an ErrorDict for the data provided for the form" if self._errors is None: self.full_clean() return self._errors
def full_clean(self): super(AddressForm, self).full_clean() if not self.is_primary: if self.is_bound and self['use_primary_address'].value(): self._errors = ErrorDict()