當前位置:編程學習大全網 - 源碼下載 - flask-xadmin自帶後臺登錄界面、權限管理使用說明

flask-xadmin自帶後臺登錄界面、權限管理使用說明

flask-xadmin其實就是集成了Flask-Admin、Flask-SQLAlchemy、Flask-Security的擴展

使用說明:

1.安裝

pip?install?Flask-Admin

pip?install?Flask-SQLAlchemy

pip?install?Flask-Security

pip?install?flask-xadmin

2.整合

可以參考作者在2016.12月寫的例子

.readthedocs.io/zh_CN/latest/models.html)

app.config['SECURITY_PASSWORD_HASH']和app.config['SECURITY_PASSWORD_SALT']是必須的

password字段的長度不得低於120,User模型裏的所有字段char長度之和不能超過1000

其他地方直接照搬例子即可。

其中要註意的是

views=[

myModelView(model=User,session=db.session,category='Entities'),

myModelView(model=Role,session=db.session,category='Entities'),

myModelView(model=Mydata,session=db.session,category='Entities'),

myFileAdmin(base_path='.',name="Files",category='Files']

需要修改,在category屬性後面再添加endpoint屬性,即:

views=[

myModelView(model=User,session=db.session,category='Entities',endpoint="User"),

myModelView(model=Role,session=db.session,category='Entities',endpoint="Role"),

myModelView(model=Mydata,session=db.session,category='Entities',endpoint="Mydata"),

myFileAdmin(base_path='.',name="Files",category='Files',endpoint="files")]

不然會報錯藍圖重復錯誤:

AssertionError: A blueprint's name collision occurred between and . Both share the same name "workflow". Blueprints that are created on the fly need unique names.

  • 上一篇:壹個準備自學VB的人提問——(高手進、高分)
  • 下一篇:dede單頁調用出源碼怎麽解決
  • copyright 2024編程學習大全網