更新出错 python 3.5 django 1.8.2-1.9.2
data = {
"state": "ok",
"errmsg": "",
"data": [
{"uid": "454",
"username": "44",
"time": "2016-1-15 11:40:01"
},
{"uid": "111123",
"username": "66",
"time": "2016-2-12 11:40:01"
}
]
}
for i in data['data']:
sj = Test.objects.all()
yz = sj.filter(uid=i['uid'],time=i['time'])
if not yz:
print('不存在')
Test.objects.create(uid=i['uid'], time=i['time'], username=i['username'])
else:
print('已存在')
Test.objects.update(uid=i['uid'], time=i['time'], username=i['username'])
如果我要知道我插入了多少条和更新了多少条怎么弄