错误信息如下:
flask_sqlalchemy\__init__.py:800: UserWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future. Set it to True to suppress this warning.
warnings.warn('SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future. Set it to True to suppress this warning.')
错误信息提示的很明确,修改 SQLALCHEMY_TRACK_MODIFICATIONS 为True以移除这个警告。
尝试进行了如下修改:
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True
然而并没有什么卵用。去flask_sqlalchemy的init.py里面修改吧。
在init.py里面有init_app方法,修改下面的一行:
track_modifications = app.config.setdefault('SQLALCHEMY_TRACK_MODIFICATIONS', True)
然后保存,重新运行。搞定!