I am having trouble to open a web page at the specific position from django view. After submitting a form, I wish it display where it was, but I cannot know where it has to be on the template itself, since that information is in form values.
Asked
Active
Viewed 193 times
0
-
Hi and welcome on StackOverflow! :) Add your code, framework versions and all related information to help us to understand your problem. – Louis Barranqueiro Dec 29 '15 at 13:37
-
1Are you looking for this: http://stackoverflow.com/questions/16388772/maintain-scroll-position-of-large-html-page-when-client-returns ? – karthikr Dec 29 '15 at 14:06
1 Answers
0
Sounds like you need to define your success url as the same page from where the form was submitted, plus an anchor.
For example:
from os.path import join
class MyFormView(FormView):
template_name='some_form_template.html'
def get_success_url(self):
"""
Returns the supplied success URL.
"""
return join(reverse('viewname'), '#anchor')
In your some_form_template.html
template:
<a id="anchor">Where you'd like the user to be dropped on the page.</a>
If your form validation was successful, the page will refresh and the user will be dropped to the anchor specified on that template.

Patrick Beeson
- 1,667
- 21
- 36