0
我无法在django视图的特定位置打开网页。提交表单后,我希望它显示它的位置,但我无法知道它必须位于模板本身的哪个位置,因为该信息具有表单值。如何从Django视图定位页面?
我无法在django视图的特定位置打开网页。提交表单后,我希望它显示它的位置,但我无法知道它必须位于模板本身的哪个位置,因为该信息具有表单值。如何从Django视图定位页面?
听起来像你需要定义你的成功url作为提交表单的同一页面,再加上一个锚点。
例如:
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')
在你some_form_template.html
模板:
<a id="anchor">Where you'd like the user to be dropped on the page.</a>
如果你的表单验证成功,页面会刷新,用户将被降至该模板的指定锚。
嗨,欢迎来到StackOverflow! :)添加您的代码,框架版本和所有相关信息,以帮助我们理解您的问题。 –
您是否正在寻找:http://stackoverflow.com/questions/16388772/maintain-scroll-position-of-large-html-page-when-client-returns? – karthikr