I don't think that spreading add_error to more places really helps with
the "more than one way to do it" issue - raising ValidationError isn't
going anywhere as documented public API. It's still the simplest thing
to do from a clean_field method, or if you want the error in
non_field_errors.
I rea
One possible way forward is to add "errors" argument to the clean()
method. Then it would be possible to use the same API everywhere by
doing errors.add_error('my_field', 'My Error message').
I don't know how strongly we feel about breakages caused by new
arguments to methods. We broke model.save(
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
On 11/18/2014 12:34 PM, Alasdair Nicol wrote:
> On 17/11/14 16:53, Carl Meyer wrote:
>> (Personally I think it would be better to document the same technique
>> for both Model.clean() and Form.clean(), because I don't think
>> Form.add_error() is significantly easier, and it breaks the API
>> consi
Hi,
Thank you Carl and Tim for your replies. I've created a ticket #23865
and written a patch [1]for the Model.clean() docs [1].
On 17/11/14 16:53, Carl Meyer wrote:
On 11/17/2014 09:48 AM, Tim Graham wrote:
The reasoning for why it wasn't documented is provided here:
https://github.com/djan
On 11/17/2014 09:48 AM, Tim Graham wrote:
> The reasoning for why it wasn't documented is provided here:
> https://github.com/django/django/pull/1443#issuecomment-28045150
That comment is actually in favor of documenting it for Model.clean(),
just suggested it be done in a separate PR.
(Personall
The reasoning for why it wasn't documented is provided here:
https://github.com/django/django/pull/1443#issuecomment-28045150
On Monday, November 17, 2014 5:21:33 PM UTC+1, Carl Meyer wrote:
>
> Hi Alasdair,
>
> On 11/17/2014 09:05 AM, Alasdair Nicol wrote:
> > Ticket #16986 (Model.clean cannot
Hi Alasdair,
On 11/17/2014 09:05 AM, Alasdair Nicol wrote:
> Ticket #16986 (Model.clean cannot report errors on individual fields)
> was fixed in Django 1.7, but the new feature is not documented. The
> Model.clean() docs still state:
>
>> Any ValidationError exceptions raised by Model.clean() wi
Hi,
Ticket #16986 (Model.clean cannot report errors on individual fields)
was fixed in Django 1.7, but the new feature is not documented. The
Model.clean() docs still state:
> Any ValidationError exceptions raised by Model.clean() will be stored
> in a special key error dictionary key, NON_FI