I'm trying to receive a post request in my view from another site but I'm receiving this error in my view:
Forbidden <span>(403)
CSRF verification failed. Request aborted.
Reason given for failure:
CSRF cookie not set.
This is my view:
@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')
I already checked the documentation and added csrf_exempt and requires_csrf_token