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

django post方法不能提交

时间:2015-12-22 10:24:03      阅读:219      评论:0      收藏:0      [点我收藏+]

标签:

def login(request):
    if request.method == ‘GET‘:
        c = {}
        c.update(csrf(request))
        return render_to_response("login.html", c)
    elif request.method == ‘POST‘ and ‘username‘ in request.POST and request.POST[‘username‘]:
        c = {‘name‘ :‘username‘}
        response = render_to_response("index.html")
        response.set_cookie("username", request.POST[‘username‘])
        return response
    else:
        return Http404

step one:

在提交post 表单前,csrf_token 必须有值。

{% csrf_token %}

django post方法不能提交

标签:

原文地址:http://www.cnblogs.com/pyfreshman/p/5065609.html

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