我想檢索json數據並將其放到數據庫中。 我正在使用django錯誤:「CSRF驗證失敗。請求中止。「與Django使用jQuery json時
當我發佈json我收到此錯誤: 禁止(403) CSRF驗證失敗。請求中止。
代碼
def receiver(request):
try:
json_data = request_to_json(request)
# Retrieving json data
x = json_data['x']
y = json_data['y']
z = json_data['z']
# put it in database
db = db_connection().db;
db_manager= db_management(db);
db_manager.insert_point(x,y,z,x);
db.close()
# A variable to return to the app
response = 'OK'
except:
response = 'Error'
return HttpResponse(simplejson.dumps(response))