有没有办法限制 ModelView 列的大小(长度/宽度)?我使用的是 WYSIWYG 编辑器,这会创建非常长的文本,因此使 ModelView 的列非常长。
这是它的外观图片。查看右侧最后一列。它甚至比屏幕截图可以处理的还要长。
最佳答案
不显示列(通过排除):
class MyView(ModelView):
column_exclude_list = ('description')
不显示列(通过包含):
class MyView(ModelView):
column_list = ('rating', 'category_id', 'year', 'stock', 'image')
重新格式化列:
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,
}
关于python - 减少 Flask-Admin 中列的大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41072317/