【发布时间】:2014-10-20 21:19:45
【问题描述】:
我想检索 json 数据并将其放入数据库。 我正在使用 django
当我发布 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))
【问题讨论】: