Re: Documenting reporting errors on individual fields in Model.clean (#16986)

2014-11-20 Thread Carl Meyer
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

Re: Documenting reporting errors on individual fields in Model.clean (#16986)

2014-11-19 Thread Anssi Kääriäinen
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(

Re: Documenting reporting errors on individual fields in Model.clean (#16986)

2014-11-19 Thread Loic Bistuer
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

Re: Documenting reporting errors on individual fields in Model.clean (#16986)

2014-11-19 Thread Carl Meyer
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

Re: Documenting reporting errors on individual fields in Model.clean (#16986)

2014-11-18 Thread Alasdair Nicol
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

Re: Documenting reporting errors on individual fields in Model.clean (#16986)

2014-11-17 Thread Carl Meyer
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

Re: Documenting reporting errors on individual fields in Model.clean (#16986)

2014-11-17 Thread Tim Graham
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

Re: Documenting reporting errors on individual fields in Model.clean (#16986)

2014-11-17 Thread Carl Meyer
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

Documenting reporting errors on individual fields in Model.clean (#16986)

2014-11-17 Thread Alasdair Nicol
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