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

后端 未结 5 427
不思量自难忘°
不思量自难忘° 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:23

    from django.http import HttpResponseRedirect
    
    def someview(request):
    
       ...
       return HttpResponseRedirect(request.META.get('HTTP_REFERER'))
    

    taken from: https://stackoverflow.com/a/12758859/14020019

提交回复
热议问题