kst*_*ich 1 python flask flask-sqlalchemy twitter-bootstrap flask-admin
有没有办法限制ModelView列的大小(长度/宽度)?我正在使用WYSIWYG编辑器,这会创建非常长的文本,因此使得ModelView的列非常长.
这是它的样子的图片.查看最后一列的右侧.它甚至比屏幕截图所能处理的还要长.
不显示列(通过排除):
class MyView(ModelView):
column_exclude_list = ('description')
Run Code Online (Sandbox Code Playgroud)
不显示列(通过包含):
class MyView(ModelView):
column_list = ('rating', 'category_id', 'year', 'stock', 'image')
Run Code Online (Sandbox Code Playgroud)
重新格式化列:
class MyView(ModelView):
def _description_formatter(view, context, model, name):
# Format your string here e.g show first 20 characters
# can return any valid HTML e.g. a link to another view to show the detail or a popup window
return model.description[:20]
column_formatters = {
'description': _description_formatter,
}
Run Code Online (Sandbox Code Playgroud)