python - 如何在 Jinja 2 html 表中显示 Python Flask DB 整体
问题描述
我目前有一个数据库,我想通过特定路线在我的网络应用程序中查看其表。
我想通过应用程序在一个易于阅读的表格中查看数据库中整体的 Jinga2 输出。
我目前拥有的作品,但它在一行中显示所有条目,而不是像 Excel 电子表格那样的表格格式。
我的代码如下:
{% for row in rows %} <tr>
<td>{{ row.id }}</a></td>
<td>{{ row.question }}</td>
<td bgcolor="{{ row.stat_colour }}">{{ row.unit_status }}</td> </tr> >
{% endfor %}
解决方案
对于任何有类似问题的人,我可以通过为我的 html 使用下面的代码块来让它工作:
<html !DOCTYPE>
<head>
<title>SQLite 3 DB Questions Table</title>
</head>
<body>
<table>
{% for row in rows %}
<tr>
<td>{{ row.id }}</td>
<td>{{ row.question }}</td>
</tr>
{% endfor %}
</table>
</body>
</html>
推荐阅读
- python - 更新类实例变量时,最好在函数内更新还是返回值并在函数调用时更新?
- javascript - 如何在 JS 中获取网页的图片
- php - Hubspot CRM API:如何过滤联系人并显示所需的属性
- python - 可执行文件显示即使在 Conda 环境中安装了软件包,也找不到模块
- r - 滚动窗口回归的 T 统计量
- zsh - 管道 fzf 选择到文本操作到 zsh 提示符(不执行)
- pandas - 熊猫取 N 最大忽略 0
- c# - 如何在 UWP 桌面应用程序中使用 Win2D 将文本转换为图像?
- bpf - 比较 BPF 中的字符串时出现错误的地址错误
- django - 我似乎找不到从我的 django 应用程序写入 heroku 的 postgres 的方法