json转字典 存入mysql 报错 Python3.5 django1.82以上
字典:
dialogue={
"state": "ok",
"errmsg": "",
"data": {
"total": 26,
"items": [
{
"id": "83013",
"session_id": "664565",
"chat_id": "5464",
"site_id": "5464",
"visitor_id": "645645",
"worker_id": "65466",
"interface": "554",
"entry_type": "44",
"finished_type": "45",
"total_messages": "17",
"visitor_messages": "9",
"robot_messages": "2",
"miss_messages": "9",
"worker_messages": "6",
"wait_times": "0",
"total_times": "531",
"server_date": "2017-05-01",
"first_time": "2017-05-01 22:17:57",
"last_time": "2017-05-01 22:26:48",
"first_resp": "22632",
"avg_resp": "28985",
"robot_tags": "",
"manual_tags": ""
},
{
"id": "83013",
"session_id": "664565",
"chat_id": "5464",
"site_id": "5464",
"visitor_id": "645645",
"worker_id": "65466",
"interface": "554",
"entry_type": "44",
"finished_type": "45",
"total_messages": "17",
"visitor_messages": "9",
"robot_messages": "2",
"miss_messages": "9",
"worker_messages": "6",
"wait_times": "0",
"total_times": "531",
"server_date": "2017-05-01",
"first_time": "2017-05-01 22:17:57",
"last_time": "2017-05-01 22:26:48",
"first_resp": "22632",
"avg_resp": "28985",
"robot_tags": null,
"manual_tags": null
}]}}
-------------------------------------------
代码:
for records in dialogue['data']['items']:
dialogue_records = Dialogue.objects.all()
dialogue_validation = dialogue_records.filter(session_id=records['session_id'], chat_id=records['chat_id'])
if not dialogue_validation:
print("数据不存在,添加添加数据中ing....")
Dialogue.objects.create(session_id=records['session_id'], chat_id=records['chat_id'],
site_id=records['site_id'],
visitor_id=records['visitor_id'], worker_id=records['worker_id'],
interface=records['interface'],
entry_type=records['entry_type'], finished_type=records['finished_type'],
total_messages=records['total_messages'],
visitor_messages=records['visitor_messages'],
robot_messages=records['robot_messages'], miss_messages=records['miss_messages'],
worker_messages=records['worker_messages'], wait_times=records['wait_times'],
total_times=records['total_times'],
server_date=records['server_date'], first_time=records['first_time'],
last_time=records['last_time'], first_resp=['first_resp'],
avg_resp=records['avg_resp'], robot_tags=records['robot_tags'],
manual_tags=records['manual_tags'])
------------------===========
报错
model 问题我model 咩设计好 出现的