《Flask Web开发》里的坑

《Flask Web开发》这本书被奉为Flask经典。然而,这本薄薄的书里藏满了坑。

由于Flask的开源性质,Python本身的升级等诸多原因,现在这本书里的示例已经各种不兼容,我在学习过程中深受其苦,列出共勉。


一、本书英文已升级到第二版,然而国内买不到,github代码却升级了,第一版代码git在这里:

For Readers of the First Edition of the Book

The code examples for the first edition of the book were moved to a different repository: https://github.com/miguelgrinberg/flasky-first-edition.


二、关于Flask的扩展

Flask是个极微小的框架,与Django不同,Flask通过扩展来增加功能。

1.Flask所有的扩展模块命名规则由 flask.ext.modelname 改为 flask_modelname,如:

Flask-BootStrap扩展原来是:

from flask.ext.bootstrap import Bootstrap

现在是:

from flask_bootstrap import Bootstrap


三、表单扩展

这里变化较多,第一个高亮改为DataRequired,第三个同样是。第二个改为FlaskForm.

原文地址:https://www.cnblogs.com/devlige/p/8717726.html