我正试图在我的视图中从另一个网站收到一个帖子请求,但我在视图中收到此错误:
Forbidden <span>(403)
CSRF verification failed. Request aborted.
Reason given for failure:
CSRF cookie not set.
这是我的观点:
@csrf_exempt
@requires_csrf_token
def notificacao(request):
if request.method == 'POST':
notification_code = request.POST['notificationCode']
if notification_code:
url = 'https://ws.pagseguro.uol.com.br/v2/transactions/notifications/' + notification_code + '?email=filipe.ferminiano@gmail.com' + '&token=token'
r = requests.get(url)
print r['status']
if r['status']:
b = teste(name = r['status'])
else:
b = teste(name = 'teste errado')
b.save()
print 'r ' + r
return render(request, 'obrigado.html',{'code':notification_code})
else:
print 'notification code is null'
b = teste(name = 'sem notification code')
b.save()
return render(request,'obrigado.html')
else:
b = teste(name = 'sem metodo post')
b.save()
return render(request, 'obrigado.html')
我已经检查过文档并添加了csrf_exempt和requires_csrf_token