Hi Alasdair,
 

> I'm upgrading to Django 1.7, and updating my forms to use the new 
> form.add_errors() method. 
>
> I have one remaining pattern which uses form._errors. 
>
> class MyForm(forms.Form): 
>      ... 
>      def clean(): 
>         cleaned_data = super(MyForm, self).clean() 
>         if not self._errors: 
>             do_something() 
>
> I only want to call do_something() if no errors have been found during 
> the validation so far. I'd rather not use self._errors, since it is now 
> a private API according to the release notes [1]. What's the recommended 
> way to replace self._errors here? 
>
> Is it ok to use self.errors instead? Looking at the source code [2], 
> errors is a property, not an attribute. By the time the clean() method 
> is called, self._errors should have been created, so I think that 
> accessing self.errors should be safe.
>

The doc says it's ok.
"Since the field validation methods have been run by the time clean() is 
called, you also have access to the form’s errors attribute which contains 
all the errors raised by cleaning of individual fields."

https://docs.djangoproject.com/en/dev/ref/forms/validation/#form-subclasses-and-modifying-field-errors

Collin

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8666367e-4186-4dce-8c18-341e7d819f31%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to