2
我使用的是鍍鉻郵遞員擴展來測試Django的請求和響應的功能,我將需要POST數據到一個Django應用程序POST錯誤。我的應用程序的看法是:
def index(request):
# loop through keys
for key in request.POST:
value = request.POST[key]
# loop through keys and values
output =""
for key, value in request.POST.iteritems():
output= output + str(key) + " " + str(value) + "<br>"
return HttpResponse(output)
當我發送請求我得到:
Forbidden (403)
CSRF verification failed. Request aborted.
Help
Reason given for failure:
CSRF cookie not set.
我該如何解決這個問題?
編輯:這是你的建議更改後的輸出:
謝謝praveen,你懂了!請參閱上面的更新。 – user61629
謝謝。我無法在其他地方找到解決方案 – Ryan