Django: Redirect to same page after POST method using class based views

后端 未结 5 407
不思量自难忘°
不思量自难忘° 2020-12-28 14:05

I\'m making a Django app that keeps track of tv show episodes. This is for a page on a certain Show instance. When a user clicks to add/subtract a season, I want the page to

5条回答
  •  自闭症患者
    2020-12-28 14:35

    to redirect to the same page (e.g. an http GET) after a POST, I like...

    return HttpResponseRedirect("")   # from django.http import HttpResponseRedirect
    

    it also avoids hardcoding the show:detail route name, and is a lil' clearer intention wise (for me at least!)

提交回复
热议问题