您好我试图做这样的事情
$http({
url: '/',
method: "POST",
data: $.param('test=data'),
headers: {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
}
})
在django
#urls
url(r'^$', myView),
#views
def myView(request):
if request.method == "POST":
print "POST", request.POST
return render(request, 'index.html')
但我只能得到这个:POST / 403 FORBIDDEN
答案 0 :(得分:1)
在myView功能之前的行上添加@api_view(['POST'])
:
@api_view(['POST'])
def myView(request):
//so on