如何解决在CS50 Finance解决方案中不显示历史记录表
我目前正在努力解决CS50的财务解决方案。
似乎我已经成功地完成了历史记录表之外的所有操作,因为当单击历史记录链接时,没有显示任何内容,但是我也没有收到任何错误消息...
这是我在application.py中的历史代码:
@app.route("/history")
@login_required
def history():
rows = db.execute("SELECT * FROM transactions WHERE user_id = :user",user=session["user_id"])
transactions = []
for row in rows:
stock_info = lookup(row['symbol'])
if row['isbought'] == '0':
row['value'] = "-" & row['value']
transactions.append(list((stock_info['symbol'],stock_info['name'],row['shares'],usd(row['value']),row['transacted'])))
return render_template("history.html",transactions=transactions)
这是我的history.html:
{% extends "layout.html" %}
{% block title %}
History
{% endblock %}
{% block body %}
<table class="table">
<thead>
<th>SYMBOL</th>
<th>NAMES</th>
<th>SHARES</th>
<th>VALUE</th>
<th>DATE</th>
</thead>
<tbody>
{% for transaction in transactions %}
<tr>
<th scope="row">{{ transaction[0] }}</th>
<td>{{ transaction[1] }}</td>
<td>{{ transaction[2] }}</td>
<td>{{ transaction[3] }}</td>
<td>{{ transaction[4] }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endblock %}
如果您需要查看我的其余代码,请在下面发表评论。我将非常感谢您调试我的工作方面的帮助!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。