这个软件包已经进入维护模式!
我很抱歉地宣布,flask-peewee 现在将进入只维护模式。这个决定是出于多种因素的考虑。
Flask-Admin 提供了一个优秀的管理界面,并且支持 peewee 模型。
Flask-Security 和 Flask-Login 都提供了认证功能,并且与 Peewee 配合得很好。
不过最重要的是,我发现自己并不想在 flask-peewee 上工作。
我计划重写 flask-peewee 的数据库和 REST API 部分,并将它们重新打包成一个新的库,但 flask-peewee 目前的状态将只处于维护模式。
flask-peewee
在 flask web 框架和 peewee orm 之间提供了一层集成。
内置功能:
- 管理界面
- 认证
- rest api
要求
- flask
- peewee
- wtforms
- wtf-peewee
- python 2.5 或以上
查看文档。
管理接口
在很大程度上受到 django admin 的影响,为你的项目提供了简单的创建/编辑/删除模型的功能。
rest api
受 tastypie 的影响,提供了一种为你的项目模型提供 RESTful 接口的方法。
curl localhost:5000/api/user/ { "meta": { "model": "user", "next": "", "page": 1, "previous": "" }, "objects": [ { "username": "admin", "admin": true, "email": "", "join_date": "2011-09-16 18:34:49", "active": true, "id": 1 }, { "username": "coleifer", "admin": false, "email": "coleifer@gmail.com", "join_date": "2011-09-16 18:35:56", "active": true, "id": 2 } ] }
安装
我建议在 virtualenv 中安装,以便开始使用。
# create a new virtualenv virtualenv --no-site-packages project cd project/ source bin/activate # install this project (will install dependencies as well) pip install flask-peewee
示例应用
要启动这个示例应用程序,请将目录 cd 到 "example" 目录下,并执行 run_example.py 脚本。
cd example/ python run_example.py
如果你想测试管理区,以 "admin/admin" 的身份登录,然后导航到。
你可以在以下网址查看REST api。
http://127.0.0.1:5000/api/message/
(The first version translated by vz on 2020.09.13)