![](/img/trans.png)
[英]python 3.7.4 : FLASK_SQLALCHEMY No module named '_sqlite3'
[英]how to print results of sqlite3 on html using flask_sqlalchemy
大家好,開發人員。 我已經搜尋了幾個小時並閱讀了一段時間的文檔,但是我似乎無法將allmodels的內容打印到html文件中
#python file
@app.route('/models')
#@login_required
def models():
allmodels = Modeldb.query.all() #THIS RETURNS A LIST FORM SQLITE3
return render_template('models.html', allmodels=allmodels)
這是HTML文件
<html>
<head>
<body class = "body">
<body>
<h1> HELLOO </h1>
{% for models in allmodels %}
<p> {{ models }} </p>
{% endfor %}
</body>
</head>
</html>
它輸出
HELLOO <位於0xb5db0bcc的主要 .Modeldb對象>
<位於0xb5db0c8c的主要 .Modeldb對象>
<位於0xb5db0c0c的主要 .Modeldb對象>
<位於0xb5db0ccc的主要 .Modeldb對象>
<位於0xb5db0d0c的主要 .Modeldb對象>
<位於0xb5db0d4c的主要 .Modeldb對象>
<位於0xb5db0d8c的主要 .Modeldb對象>
我知道我親密。 或者可能不是。 :)在此先感謝你們,更多的精力給你們;))))
好的。 所以我想通了。
{% for models in allmodels %}
{{row["column_name_here"]}}
{{row["another_column_name_here_if_u_want"]}}
{% endfor %}
這基本上可以做到。 :)
恭喜你弄明白了 :)。 還無法發表評論,因此請使用其他語法添加此帖子:
{% for models in allmodels %}
{{models.column_name_here}}
{{models.column2_name_here}}
{% endfor %}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.