cannot you 'redirect' to the whole url like this: if form.is_valid(): thank you page else: *return redirect('http://www.test.com/form#filled') * * * or you can also redirect just to /form#form/ i think...
* * * * Am Freitag, 11. Mai 2012 23:43:50 UTC+2 schrieb brian: > > I have form that is toward the bottom of a web page. If someone > submits some bad data, I want the page to scroll to the form. > Currently if the data is bad, I can see the page get refreshed and the > browser scrolls to the top of the screen. When I get an error in a > submitted form, how do I get it to scroll to the form? > > I found this [1] where it scrolls after the form is submitted. I only > want it to scroll when the form has an error. After the form is > submitted successfully, I redirect to a thank you page. > > One idea I had in the view was to do something like: > ------------------------- > if form.is_valid(): > …. > else: > return HttpResponseRedirect(request.path + '#formId') > ------------------------- > The form doesn't show the error fields when I do this. Also this > seems to break the MTV model since I putting the div id in the view. > > Brian > > [1] > http://stackoverflow.com/questions/3036273/django-how-do-i-position-a-page-when-using-django-templates -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/WToV2i8r1_sJ. 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.