且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

创建对象后重新定向,Django

更新时间:2023-12-05 12:37:34

在您看来,在处理表单之后,可以使用 HttpResponseRedirect()来设置适当的网址重定向到新页面。请参阅文档:使用视图中的表单

In your view, using HttpResponseRedirect() to appropriate url after processing a form you can redirect to new page. Refer doc: Using a form in a view

更新:重定向到ID为id的匹配页面

Update : to redirect to match page with id

如果您的比赛详细信息页面的网址是这样的:

If your url for match detail page is something like this:

url(r'^match_detail/(?P<id>\d+)/$', 'myapp.views.match_detail', name='un_mdetail'),

然后您可以使用此重定向

Then you can redirect using this

HttpResponseRedirect(reverse('un_mdetail', args=(match.id,)))