flask-admin

it2022-05-05  185

flask-admin
初始化

class Admin(app=None, name=None, url=None, subdomain=None, index_view=None, translations_path=None, endpoint=None, static_url_path=None, base_template=None, template_mode=None, category_icon_classes=None)

from flask import Flask from flask.ext.admin import Admin app = Flask(__name__) admin = Admin(name='op', template_mode='bootstrap3') admin.init_app(app)
导航条

1 class BaseView(name=None, category=None, endpoint=None, url=None, static_folder=None, static_url_path=None, menu_class_name=None, menu_icon_type=None, menu_icon_value=None)

2 expose(url='/', methods=('GET', ))

3 is_accessible()

4 is_visible()

5 render(template, **kwargs)

from flask.ext.admin import BaseView, expose class MyView(BaseView): @expose('/') def index(self): return 'Hello World!' # 菜单图标 admin.add_view(MyView(name='My View', menu_icon_type='glyph', menu_icon_value='glyphicon-home'))
数据表

class ModelView(model, session, name=None, category=None, endpoint=None, url=None, static_folder=None, menu_class_name=None, menu_icon_type=None, menu_icon_value=None)

column_select_related_list

class PostAdmin(ModelView): column_select_related_list = (Post.user, Post.city)

column_searchable_list

class MyModelView(ModelView): column_searchable_list = (User.name, User.email)

column_filters

class MyModelView(BaseModelView): column_filters = ('user', 'email') from flask.ext.admin import Admin, expose from flask.ext.admin.contrib.sqla import ModelView, filters from flask.ext.sqlalchemy import SQLAlchemy posted on 2016-04-05 11:28 北京涛子 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/liujitao79/p/5354348.html

相关资源:各显卡算力对照表!

最新回复(0)