Dan*_*345 1 python flask twitter-bootstrap
我刚开始使用 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)
但这根本行不通...
任何提示将不胜感激!
小智 5
正如flask table 文档中提到的,您可以通过将类table添加到python 对象的classes属性来将类添加到dom Table。
在你的情况下,它会是这样的:
class ResultTable(Table):
classes = ['table', 'table-striped', 'table-bordered', 'table-condensed']
guestid = Col ('ID', show=False) #unique identifier for each entry
name = LinkCol('Name', 'edit', url_kwargs=dict(id='guestid'),attr='name') #clicking on this
email = Col('Email') #email address for each entry
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2804 次 |
| 最近记录: |