Django return HttpResponseRedirect to an url with a parameter

前端 未结 5 680
面向向阳花
面向向阳花 2020-12-24 11:24

I have a situation in my project where i need to make a redirection of the user to an url containing a parameter, (it is declared in the urls.py like:

url(r         


        
5条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-24 12:15

    When everything seems not to be working i use return render and check if it is post request in case anybody refresh the page

    if request.POST:
        message = "Thank you."
        return render(request, 'index.html', locals())
    return HttpResponseRedirect('/')
    

    The local() make the parameter accessible on the template

提交回复
热议问题