Django表单重定向 [英] Django form redirect
本文介绍了Django表单重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个表单,用户填写此表单后,我想重定向到一个这样的URL
r'^ user /(?P< id> \d +)/ $'
< id>
是数据库中的主要关键...我如何去了这个coz我被困在这一点上。
解决方案
好的,所以在你的.html文件中,你应该有一个action =在你的窗体中,哪种类似正则表达式。至少应该看起来类似于:
action =/ user / {{object.id}} /
object.id将替换为视图中传递给html文件的任何对象。 p>
I have a form that and after the user fills in this form, I want to redirect to a URL that looks something like this
r'^user/(?P<id>\d+)/$'
The <id>
is the primary key in the database...how do I go about this coz I'm stuck at this point
解决方案
Ok, so in your .html file, you should have an action= in your form, which sort of looks like that regular expression. At the very least it should look something similar to:
action="/user/{{ object.id }}/"
object.id would be replaced with whatever object you passed to the html file in your view.
这篇关于Django表单重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文