解决办法:引入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)