用tornado写了一个小程序一直报错

2014-02-09 18:52:15 +08:00
 o618
self.topic_model.update_topic_by_topic_id(topic_id, {"up_vote": template_variables["votes"],})

template_variables["votes"] = self.vote_model.get_vote_by_topic_id_and_trigger_user_id(topic_id, self.current_user["uid"])

想对某个话题进行投票数统计,但运行一直报错:"up_vote": template_variables["votes"],
KeyError: 'votes'
3201 次点击
所在节点    问与答
4 条回复
o618
2014-02-09 18:54:04 +08:00
弄了一下午都没弄好,怎么破?
whtsky
2014-02-09 21:28:24 +08:00
把第二句放倒第一句前面…
o618
2014-02-09 22:47:44 +08:00
@whtsky 放到前面又抛出这个错误:

File "/usr/local/lib/python2.7/dist-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
raise errorclass, errorvalue
OperationalError: (1366, "Incorrect integer value: '<bound method VoteModel.get_vote_by_topic_id_and_trigger_user_id of <model.vote.VoteModel object at 0x8c9544c>>' for column 'up_vote' at row 1")
[E 140209 22:43:49 web:1635] 500 GET /t/7 (127.0.0.1) 65.44ms
kevinkim
2014-02-10 09:03:59 +08:00
看看数据库字段名是否叫“up_vote”,其次,
self.topic_model.update_topic_by_topic_id(topic_id, {"up_vote": template_variables["votes"],})

最后一个逗号删除看看。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/99463

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX