Redirection after creating an object, Django

后端 未结 1 411
小蘑菇
小蘑菇 2020-12-22 07:55

I\'m new with Django and I\'m creating a sport app. I allow users to create a match (choosing their team and their style), and I want to redirect them to a specific page (t

相关标签:
1条回答
  • 2020-12-22 08:34

    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

    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,)))
    
    0 讨论(0)
提交回复
热议问题