On Aug 22, 2013, at 4:29 AM, Wim Feijen wrote:
> How about:
>
> form.add_errors(dictionary)
That's actually supported, although you need to nullify `field` explicitly:
`form.add_errors(None, dictionary)`.
It's mostly used internally; I'm not sure it's really useful to document, since
most li
Hi Loic,
That's nice! It looks very powerful, saving lines of code and being more
clear.
How about:
form.add_errors(dictionary)
? Because then we can either add one or more errors at the same time.
Wim
On Wednesday, 21 August 2013 02:31:07 UTC+2, Simon Litchfield wrote:
>
> An improvement
An improvement for sure. Any reason it can't be a little more pythonic, ie
using optional kwargs etc?
My only concern is in having two ways of achieving the same thing. If the
latter is simpler and more flexible, does this place our entire
ValidationError approach to handling form and model err
Yeah I'm definitely on the "document add_error first, ValidationError(dict)
as a more powerful alternative". The second option is necessary to do
clever things directly from Model.clean()
Marc
On 20 August 2013 07:07, Anssi Kääriäinen wrote:
> On 08/20/2013 08:26 AM, Loic Bistuer wrote:
>
>> A
On 08/20/2013 08:26 AM, Loic Bistuer wrote:
An alternate would be to implement a method that does this.
def field_error(self, name, error):
self._errors = self._errors or ErrorDict()
self._errors.setdefault(name, ErrorList())
self._errors[name].append(error)
I also have a pending
> An alternate would be to implement a method that does this.
>
> def field_error(self, name, error):
> self._errors = self._errors or ErrorDict()
> self._errors.setdefault(name, ErrorList())
> self._errors[name].append(error)
I also have a pending PR for that: https://code.djangoproj
+1 on a better way to do field errors.
An alternate would be to implement a method that does this.
def field_error(self, name, error):
> self._errors = self._errors or ErrorDict()
> self._errors.setdefault(name, ErrorList())
> self._errors[name].append(error)
Having to raise a Valid
There is a ticket with a PR to address the issue of targeting specific fields
when raising errors; I'm awaiting feedback on what should be the documented API.
https://code.djangoproject.com/ticket/20867.
This patch enables two patterns:
- Raising ValidationError({'field': 'error'}) from `Form.c
Lack of clean control over field-specific form errors is an issue that has
been raised and discussed many times over the years, but still the solution
seems pretty inadequate. We're even directing people hack around with
_errors and making excuses for it in the documentation.
https://docs.django