Sea*_*thy 4 python flask flask-admin
如何删除 Python Flask-Admin 库中的“Home”按钮?
from flask_admin import Admin
flask_admin = Admin(app,
name='Customer Admin',
template_mode='bootstrap3',
# endpoint refers to the blueprint [e.g. url_for('admin_cust.index')] where index() is the function/view
index_view=SecuredAdminIndexView(url='/admin_cust', endpoint='admin_cust')
)
# Add model (database table) views to the page
flask_admin_cust.add_view(UserView(User, db.session, category='Users', name='View/Edit User', endpoint='users'))
flask_admin.add_view(CustSubGroupView(CustSubGroup, db.session, name='Groups', endpoint='groups'))
flask_admin.add_view(GwView(Gw, db.session, endpoint='units', name='Units'))
Run Code Online (Sandbox Code Playgroud)
pjc*_*ham 12
Flask-AdminBaseView有一个方法is_visible(self),源码中有注释:
请注意,该项目应该是可见的并且可以在菜单中显示。
例如,索引视图可以遵循以下几行:
from flask_admin import Admin
from flask_admin import AdminIndexView
from flask_admin import expose, AdminIndexView
class DashboardView(AdminIndexView):
def is_visible(self):
# This view won't appear in the menu structure
return False
@expose('/')
def index(self):
return self.render(
'admin/dashboard.html',
)
flask_admin = Admin(app,
name='Customer Admin',
template_mode='bootstrap3',
index_view=DashboardView()
)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3034 次 |
| 最近记录: |