I am doing a simple comment submission form.
The page that the comment form is on is:
/item/2/
the comment form action url is:
/item/comment/
On the submission, I check if the form is valid, and if it is not, I
return the form to the user / template, which then displays the form
errors. If it is valid, then I redirect to the page that the form was
submitted from.
Something like this:
---
if form.is_valid()
#save comment / form input
else
return render_to_response('item/chapter.html', c,
RequestContext(request))
---
If the required fields are filled in, this works great. The comment is
entered, and the browser is redirected to the same page /item/2/
However, if the form does not validate, then the previous template is
rendered, with the form fields showing the error. However, the user is
now at the action url : /item/comment/
Is there any way to make it so the user is always on /item/2/ url? even
if returning from an invalid form submission?
The only way I can think to do this is have the URL for both the page,
and the form submission to be the same:
/item/
and then just check for GET or POST in the view. However, this seems
like a hack, and ties the form handling too closely to that particular view.
Any suggestions?
mike
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---