V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
o618
V2EX  ›  问与答

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

  •  
  •   o618 · 2014-02-09 18:52:15 +08:00 · 3172 次点击
    这是一个创建于 3736 天前的主题,其中的信息可能已经有所发展或是发生改变。
    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'
    4 条回复    1970-01-01 08:00:00 +08:00
    o618
        1
    o618  
    OP
       2014-02-09 18:54:04 +08:00
    弄了一下午都没弄好,怎么破?
    whtsky
        2
    whtsky  
       2014-02-09 21:28:24 +08:00 via iPhone
    把第二句放倒第一句前面…
    o618
        3
    o618  
    OP
       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
        4
    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"],})

    最后一个逗号删除看看。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1374 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 16:45 · PVG 00:45 · LAX 09:45 · JFK 12:45
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.