Code

Ticket #5992: errorlist.patch

File errorlist.patch, 1.8 KB (added by Max Derkachev <mderk@…>, 6 years ago)
  • django/newforms/forms.py

     
    4646    # class is different than Form. See the comments by the Form class for more 
    4747    # information. Any improvements to the form API should be made to *this* 
    4848    # class, not to the Form class. 
     49     
     50    error_class = ErrorList 
     51     
    4952    def __init__(self, data=None, files=None, auto_id='id_%s', prefix=None, 
    50                  initial=None, error_class=ErrorList, label_suffix=':'): 
     53                 initial=None, error_class=None, label_suffix=':'): 
    5154        self.is_bound = data is not None or files is not None 
    5255        self.data = data or {} 
    5356        self.files = files or {} 
    5457        self.auto_id = auto_id 
    5558        self.prefix = prefix 
    5659        self.initial = initial or {} 
    57         self.error_class = error_class 
     60        self.error_class = error_class or self.error_class or ErrorList 
    5861        self.label_suffix = label_suffix 
    5962        self._errors = None # Stores the errors after clean() has been called. 
    6063 
     
    188191                    value = getattr(self, 'clean_%s' % name)() 
    189192                    self.cleaned_data[name] = value 
    190193            except ValidationError, e: 
    191                 self._errors[name] = e.messages 
     194                self._errors[name] = self.error_class(e.messages) 
    192195                if name in self.cleaned_data: 
    193196                    del self.cleaned_data[name] 
    194197        try: 
    195198            self.cleaned_data = self.clean() 
    196199        except ValidationError, e: 
    197             self._errors[NON_FIELD_ERRORS] = e.messages 
     200            self._errors[NON_FIELD_ERRORS] = self.error_class(e.messages) 
    198201        if self._errors: 
    199202            delattr(self, 'cleaned_data') 
    200203