On Mon, Feb 21, 2011 at 4:39 PM, ju <julian.po...@gmail.com> wrote:
> Is it possible to add form errors (not a field specific errors) to a
> form that is already validated (form.is_valid() is already called and
> the result is True)?
>
> I have additional validation logic (with database requests) which I
> prefer to execute after standard form validation is passed, but it
> will be better to associate new errors with form
>
> Or maybe I have to call this additional validation within clear() form
> function?
>
> P.S. I don't have a model involved in these database requests, it's a
> raw sql that call one database function. And the result can indicate
> incorrect data in form, that's why I want to associate errors with
> form
>
> Also here: http://stackoverflow.com/questions/5067843/django-form-validation
>

You should do all your additional validation from clean(). Either
raise forms.ValidationError, or if you want to add multiple error
messages, or add errors to specific fields, then directly manipulate
Form._errors [1]. This should still happen from clean(), so that
is_valid() returns the correct value.

Cheers

Tom

[1] 
http://docs.djangoproject.com/en/1.2/ref/forms/validation/#form-subclasses-and-modifying-field-errors

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to