On Jan 12, 2008 6:26 AM, cesco <[EMAIL PROTECTED]> wrote:

>
> Hi,
>
> I'm a bit puzzled by the following behaviour of newforms.
>
> I have a field in the form called 'seller'.
>
> In the form validation I have a clean_seller method which if a certain
> condition is verified will do the following:
>
> self.errors.update(seller = ErrorList([u"message1: the indicated
> seller doesn't exist in our database"]))
> raise forms.ValidationError(u"message2: seller doesn't exist")
>
> In the template I have the following:
>
> <div class="error-msg">{{ monitor_f.seller.errors|join:", " }}</div>
>
> I would expect the first message (that is: "message1: the indicated
> seller doesn't exist in our database") to be displayed in case of
> error and I thought that the forms.ValidationError was just an
> exception raised to stop the validation. Instead the second message
> (the one contained in forms.ValidationError is displayed).
>
> Probably there is something I'm missing. Would anyone help me
> understand?
>

From
http://www.djangoproject.com/documentation/newforms/#custom-form-and-field-validation
:

"If you detect multiple errors during a cleaning method and wish to signal
all of them to the form submitter, it is possible to pass a list of errors
to the ValidationError constructor."

So, you can accumulate your list of errors and pass them all to
ValidationError at once.

Karen

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to