CSRF 验证失败。请求因 csrf_exempt 中止

use*_*563 5 python django

我试图在我的视图中从另一个站点接收一个发布请求,但我在我的视图中收到此错误:

Forbidden <span>(403)
CSRF verification failed. Request aborted.

    Reason given for failure:
    CSRF cookie not set.
Run Code Online (Sandbox Code Playgroud)

这是我的观点:

@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')
Run Code Online (Sandbox Code Playgroud)

我已经检查了文档并添加了 csrf_exempt 和 requires_csrf_token