Skip to content
Advertisement

I’m not able to import Flask-WTF TextField and BooleanField

I’m using virtualenv to set up a new project. I installed a lot of things using virtualenv pip from the script folder like below:

JavaScript

I have no other packages installed in the global python folder. My code looks like this:

JavaScript

and other packages are found like sqlalchemy also installed only in the virtual environment.

The error I get is:

JavaScript

Form is found but not TextField and BooleanField. What is the problem here?

Update I just looked through some of the Flask-WTF code and found this:

JavaScript

Am I using examples from an older version or something?

Advertisement

Answer

From version 0.9.0, Flask-WTF will not import anything from wtforms, you need to import fields from wtforms.

Source

You need to import them from wtforms (note that according to docs import statement was changed):

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement