Neither will go away, `ValidationError(dict)` is used internally to carry 
errors from the model layer to the form layer, and `add_error()` is used 
internally to interpret the `ValidationError` raised throughout the system; 
basically any `raise ValidationError` is followed by a call to `add_error()`.

One benefit of `add_error()` is that it's available from outside the form 
validation methods, it's much less fiddly to add an error from a view if you 
are using `add_error()`. It also doubles as a low-level API that can be used to 
implement custom validation logic, for instance `ModelForm` uses it to plug in 
model validation.

Fore more background on `add_error()` as a public API: 
https://code.djangoproject.com/ticket/20867#comment:4

-- 
Loic

> On Nov 20, 2014, at 1:19 AM, Carl Meyer <c...@oddbird.net> wrote:
> 
> Yes, the add_error() API is slightly less verbose if you have multiple
> different errors you may want to flag. I don't think that difference is
> worth having to remember two different ways to do it, but I don't really
> feel strongly enough about it to push for what would essentially amount
> to deprecating `Form.add_error()`.
> 
> I am satisfied as long as `raise ValidationError(dict)` continues to
> work in both places, so I can use it in my code :-)

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/82DD0551-D921-4DF6-A60A-A35F2E049A78%40sixmedia.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to