我刚开始使用 Flask 和 Bootstrap,并且对如何将 Bootstrap 样式应用到 Python 在我的模板中插入的表感到困惑。
正常的html是:
<head>
<link rel="stylesheet" href="/static/bootstrap/css/bootstrap.min.css" media="screen">
</head>
<body>
{{ table }}
</body>
Run Code Online (Sandbox Code Playgroud)
我使用 flask_table 来填充我的数据,如下所示:
<head>
<link rel="stylesheet" href="/static/bootstrap/css/bootstrap.min.css" media="screen">
</head>
<body>
{{ table }}
</body>
Run Code Online (Sandbox Code Playgroud)
然后 ResultTable 类是:
results=db.search(gsearch.name != "") #Search of tinyurl database
mytable=ResultTable(results) #put into columns
return render_template('index.html', form=search, table=mytable)
Run Code Online (Sandbox Code Playgroud)
所以我以为我会做这样的事情:
<table class="table table-striped table-bordered table-condensed">
{{ table }}
</table>
Run Code Online (Sandbox Code Playgroud)
但这根本行不通...
任何提示将不胜感激!