关于Flask mega-tutorial遇到的一些问题-二(Form更名,sqlalchemy默认值)

一、Form 更名为 FlaskForm(rename)

当运行run.py载入login界面时,会出现这样的错误:

192.168.1.3 - - [16/Apr/2017 18:38:49] "GET /index HTTP/1.1" 302 -
/home/air/Desktop/microblog/app/views.py:61: FlaskWTFDeprecationWarning: "flask_wtf.Form" has been renamed to "FlaskForm" and will be removed in 1.0.
  form = LoginForm()

字面意思,这个flask_wtf.Form更名为FlaskForm了,那,就把Form改成FlaskForm好了,
可是 app/views里面并没有Form,所以…
app/models
改成这个样子:

 from flask_wtf import FlaskForm as Form

解决~

二、设置SQLALCHEMY_TRACK_MODIFICATIONS 为True或False

/home/air/Desktop/microblog/flask/local/lib/python2.7/site-packages/flask_sqlalchemy/__init__.py:839: FSADeprecationWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future.  Set it to True or False to suppress this warning.
  'SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and '
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

是说SQLALCHEMY_TRACK_MODIFICATIONS不能默认什么都没有,
得设置其为 True 或者 False
所以就去/flask/local/lib/python2.7/site-packages/flask_sqlalchemy/__init__.py这个文件中进行更改,
提示给的839行,在前面几行的位置有这样的setdefault
把None改为True;:

...
 833            track_modifications = app.config.setdefault(
 834             'SQLALCHEMY_TRACK_MODIFICATIONS', True
 835         )
...

你可能感兴趣的:(技能心得)