码迷,mamicode.com
首页 > 其他好文 > 详细

django csrf token添加

时间:2019-04-13 19:08:25      阅读:132      评论:0      收藏:0      [点我收藏+]

标签:get   turn   ext   protect   stc   nbsp   tor   shortcut   orm   

#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>

  

 

django csrf token添加

标签:get   turn   ext   protect   stc   nbsp   tor   shortcut   orm   

原文地址:https://www.cnblogs.com/zhengze/p/10702331.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!