def _update_errors(self, errors):
        for field, messages in errors.error_dict.items():
            if field not in self.fields:
                continue
            field = self.fields[field]
            for message in messages:
                if isinstance(message, ValidationError):
                    if message.code in field.error_messages:
                        message.message = field.error_messages[message.code]

        message_dict = errors.message_dict
        for k, v in message_dict.items():
            if k != NON_FIELD_ERRORS:
                self._errors.setdefault(k, self.error_class()).extend(v)
                # Remove the data from the cleaned_data dict since it was invalid
                if k in self.cleaned_data:
                    del self.cleaned_data[k]
        if NON_FIELD_ERRORS in message_dict:
            messages = message_dict[NON_FIELD_ERRORS]
            self._errors.setdefault(NON_FIELD_ERRORS, self.error_class()).extend(messages)
dataset/ETHPy150Open cloudera/hue/desktop/core/ext-py/Django-1.6.10/django/forms/models.py/BaseModelForm._update_errors/original