flask adminlte
1.0.0
Bootstrap AdminLTE模板使用flask-admin 1.5.2和flask-security 3.0.0适应flask框架。
它有助于为用 Flask 编写的后端开发漂亮、易于使用的管理面板。
http://adminlte.najdaapps.com/admin/
登录: [email protected]
密码:管理员
将目录adminlte
、 static
、 templates
复制到您的项目中。
from flask import Flask , url_for
from flask_security import Security
from flask_admin import helpers as admin_helpers
from adminlte . admin import AdminLte , admins_store
app = Flask ( __name__ )
security = Security ( app , admins_store )
admin = AdminLte ( app , skin = 'green' , name = 'FlaskCMS' , short_name = "<b>F</b>C" , long_name = "<b>Flask</b>CMS" )
@ security . context_processor
def security_context_processor ():
return dict (
admin_base_template = admin . base_template ,
admin_view = admin . index_view ,
h = admin_helpers ,
get_url = url_for
)
class DeviceView ( BaseAdminView ):
column_editable_list = [ 'name' , 'type' , 'rooted' ]
column_searchable_list = [ 'name' , 'type' , 'rooted' ]
column_exclude_list = None
column_details_exclude_list = None
column_filters = [ 'name' , 'type' , 'rooted' ]
can_export = True
can_view_details = False
can_create = True
can_edit = True
can_delete = True
edit_modal = True
create_modal = True
details_modal = False
admin . add_view ( DeviceView ( Device , db . session , name = "Devices" , menu_icon_value = 'fa-laptop' ))
admin . add_link ( FaLink ( name = 'Website' , url = 'http://tomasznajda.com' , icon_value = 'fa-globe' , target = "_blank" ))
admin . add_view ( DeviceView ( Device , db . session , name = "Devices" , category = 'Author' , menu_icon_value = 'fa-laptop' ))
admin . add_link ( FaLink ( name = 'Website' , category = 'Author' , url = 'http://tomasznajda.com' , icon_value = 'fa-globe' , target = "_blank" ))
admin . set_category_icon ( name = 'Author' , icon_type = 'fa' , icon_value = 'fa-address-card' )
app
-> Flask 应用程序对象name
-> 例如。 FlaskCMS
。应用程序名称。将显示为页面标题。默认为“管理员”short_name
-> 例如。 <b>F</b>C
简短的应用程序名称。将显示在折叠的菜单栏中。默认情况下将使用 name 属性的值。long_name
-> 例如。 <b>Flask</b>CMS
。长应用程序名称。将显示在扩展菜单栏中以及每个安全表单上方。默认情况下将使用 name 属性的值。skin
-> AdminLTE 肤色( blue
、 black
、 puprle
、 green
、 red
、 yellow
、 blue-light
、 black-light
green-light
purple-light
red-light
yellow-light
)。默认情况下将使用blue
。url
-> 基本 URLsubdomain
-> 要使用的子域index_view
-> 要使用的主页视图。默认为AdminIndexView
。translations_path
-> 翻译消息目录的位置。默认情况下将使用 Flask-Admin 附带的翻译。endpoint
-> 索引视图的基本端点名称。如果您在单个 Flask 应用程序中使用Admin
类的多个实例,则必须为每个实例设置唯一的端点名称。static_url_path
-> 静态 URL 路径。如果提供,则指定所有视图的静态 url 目录的默认路径。可以在视图配置中覆盖。base_template
-> 覆盖所有静态视图的基本 HTML 模板。默认为admin/base.html
。 column_editable_list = [ 'from_user' , 'to_user' , 'subject' , 'content' , 'created_at' ]
column_searchable_list = [ 'from_user.first_name' , 'from_user.last_name' , 'from_user.email' , 'to_user.first_name' ,
'to_user.last_name' , 'to_user.email' , 'subject' , 'content' , 'created_at' ]
column_exclude_list = [ 'created_at' ]
column_details_exclude_list = [ 'created_at' ]
column_filters = [ 'subject' , 'content' , 'created_at' ]
can_export = True
can_view_details = True
can_create = True
can_edit = True
can_delete = True
edit_modal = True
create_modal = True
details_modal = True
SECURITY_REGISTERABLE = True
SECURITY_RECOVERABLE = True
SECURITY_CHANGEABLE = True