Few things you could do, but I think this is more of a browser / JS related topic than django.
1.) Post the form to an iframe, and in the iframe return javascript code to redirect or throw error about form content. 2.) Make the form post ajax based (bit harder, with csrf) and as above have the page act accordingly. 3.) Recommended - Use html bookmarks, put a book mark on the page with the form (on the top of the form would probably work). When redirecting back to the form page link to the book mark. ( http://www.example.com/submit_form/#theform) Either way should work, but just thinking off the top of my head -- Mike On 11 May 2012 23:43, brian <[email protected]> wrote: > 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 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. > > -- * * *Tradepage, now part of the Cloud Group, is an Authorised Google Apps for Business Reseller. For only R450 per user per year, get Business Email, Calendars, Documents, syncing with mobile devices and much more. Find out more: http://www.tradepage.co.za/google-apps-for-business* This email and all contents are subject to the following disclaimer: http://www.tradepage.co.za/disclaimer -- 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.

