djangopost请求报错:Forbidden (CSRF token missing or incorrect.)

解决办法:引入csrf_exempt包:

from django.views.decorators.csrf import csrf_exempt

然后增加装饰器:

@csrf_exempt
def register(request):  
    request.encoding='utf-8'
    if request.GET:
        return render(request,'register.html')
    elif request.POST:
        dictData = request.POST
        context = {}
        print(dictData)

猜你喜欢

转载自www.cnblogs.com/daicw/p/12053706.html