On Tue, Jun 9, 2009 at 2:19 AM, zayatzz <alan.kesselm...@gmail.com> wrote:

>
> Well thats what i was complaining about in the beginning that i could
> use good example of how to do it. Its quite confusing how form
> validation is on one page, errors on the others and views on third and
> there is not single full example.
>
> How should the else part be?
>
> else:
>    message = "form was not valid"
>    accform = form
>    ...
>    return render_to_response......
>
> something like that perhaps?
>

No, you don't want to be creating another form instance in the case where
the existing one is not valid.  The existing instance that failed validation
is already annotated with specific errors describing what's wrong with it.
Really, this example, mentioned earlier, is complete:

http://docs.djangoproject.com/en/dev/topics/forms/#using-a-form-in-a-view

There doesn't need to be an else block for the is_valid().  The case where
there are errors in the POSTed data which make the form invalid is described
by the 3rd numbered note below the example.  All that has to happen for that
case is that you pass the existing bound (and invalid, therefore containing
errors that will display with the form) back in the context for display.
The form gets re-displayed with error annotations and is ready for
correction/re-submission by the user.

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 
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