查询从数据库返回带有记录数据的字典列表。
result = [{'id': 1, 'name': 'Name 1', 'description': 'desc one...'},
{'id': 2, 'name': 'Name 2', 'description': 'desc two...'},
{'id': 3, 'name': 'Name 3', 'description': 'desc three...'}]
如何生成要发送到 html 的 ID 列表?
我正在尝试这样:
for i in result:
return render_template("dashboard.html",
user=user,
check_inner=i)
使用此选项, check_inner 不会将列表传递给 html,而只会传递列表的第一个元素。
并且您需要传递一个 ID 列表以便在 jinja2 中进行进一步处理。
好吧,也许是这样的: