views.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:two_pic 作者: onlyonebowman 项目源码 文件源码
def update_count(winner, loser):
    Session = sessionmaker()
    engine = create_engine('sqlite:///' + os.path.join(basedir, 'data-dev.sqlite'))
    Session.configure(bind=engine)
    session = Session()

    curr_usr = session.query(Post).get(winner)
    loser_guy = session.query(Post).get(loser)
    session.query(Post).filter_by(id=winner).update({'total_votes': curr_usr.total_votes+1})
    session.commit()
    flash("{} has {} votes and {} has {} votes".format(curr_usr.description, curr_usr.total_votes, loser_guy.description, loser_guy.total_votes))

    return redirect(url_for('main.index'))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号