Django局部禁用csrf_token验证
from django.views.decorators.csrf import csrf_exempt
@csrf_exempt
def index(request):
pass
# 为了好看记得把templates文件夹下的html里的{% csrf_token %}也注释掉(其实不注释掉发现也无法验证了),如:
<form action="/index/" method="post">
<!-- {% csrf_token %}-->
用户名:<input type="text" required="required" name="username" /><br />
密码:<input type="password" name="password" /><br />
<input type="submit" value="提交" />
</form>