19421608 19421608 - 6 months ago 141
Python Question

FlaskWTFDeprecationWarning with Flask_Security

I am received a warning every time I use Flask Security.

FlaskWTFDeprecationWarning: "flask_wtf.Form" has been renamed to "FlaskForm"
and will be removed in 1.0.

Is this an issue with Flask Security or something I could address myself? I am using Flask-Security==1.7.5

from flask_security import current_user, login_required, RoleMixin, Security, \
SQLAlchemyUserDatastore, UserMixin, utils

I don't seem to import Flask_WTF directly.


It looks like 1.7.5 is the latest release of Flask-Security. And the latest version of Flask-WTF is 0.13 (make sure you have that installed by checking a pip freeze).

Since you don't use Flask-WTF directly, the issue isn't your code. The issue is coming from Flask-Security's code itself, which has Flask-WTF as a dependency.

The way that Flask-Security imports the Form class from Flask-WTF is deprecated, so you're seeing the error when this line runs:

from flask_wtf import Form as BaseForm


You can either open an issue on Flask-Security (feel free to link to this question) or submit a pull request yourself to the author updating this line to the non-deprecated import

from flask_wtf import FlaskForm as BaseForm

Make sure to run tests before / after too before submitting.

For a little more context, you can use git blame to see the commit that last changed the deprecated import line in Flask-Security (6f68f1d) on August 15, 2013.

Doing the same on Flask-WTF, you can see that the deprecation was introduced in 42cc475 on June 30, 2016.