其他分享
首页 > 其他分享> > django csrf token添加

django csrf token添加

作者:互联网

#views.py

from django.shortcuts import render_to_response, RequestContext

from django.views.decorators.csrf import csrf_protect

 

@csrf_protect

def index(request):

    if request.method == "GET":

        return render_to_response("index.html", context_instance=RequestContext(request))

    else:

        return render_to_response("index.html", context_instance=RequestContext(request))

  

 

#index.html 

<form>

{% csrf_token %}

</form>

  

 

标签:index,render,RequestContext,request,django,token,html,csrf
来源: https://www.cnblogs.com/zhengze/p/10702331.html