FlaskWTFDeprecationWarning with Flask_Security

I get 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 a problem with Flask Security or something that I could solve? I am using Flask-Security == 1.7.5

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

I do not import Flask_WTF directly.

+5
source share
2 answers

1.7.5 seems to be the latest version of Flask-Security. And the latest version of Flask-WTF is 0.13 (make sure you install it by checking pip freeze ).

Since you are not using Flask-WTF directly, the problem is not in your code. The problem comes from the Flask-Security code itself, which has the -WTF flag as a dependency .

The way Flask-Security imports the Form class from Flask-WTF is deprecated, so you see an error when this line works:

 from flask_wtf import Form as BaseForm 

https://github.com/mattupstate/flask-security/blob/e01cd63a214969cf8e4ee800d398e1c43b460c7f/flask_security/forms.py#L15

You can either open the problem in Flask-Security (do not hesitate to refer to this question), or send a transfer request to the author yourself, updating this line to an uninstalled import

 from flask_wtf import FlaskForm as BaseForm 

Before sending, make sure that you have performed the tests before / after.

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

By doing the same on Flask-WTF, you can see that on August 30, 2016, the erase was introduced at 42cc475 .

+7
source

My answer is not inherent in your exact situation. However, the same warning appears when we encode this:

 from flask_wtf import Form 

To fix this problem, you should use FlaskForm instead of Form :

 from flask_wtf import FlaskForm 

This is highlighted on GitHub , and I just want to share this solution to help any possible artist who might run into him in the future.

+4
source

Source: https://habr.com/ru/post/1257481/


All Articles