I have a flask app that uses wtforms.
I have a file which does:
from wtforms.fields.html5 import DateField, EmailField, TelField
# rest of the file
I just wanted to rebuild my docker container and now I have this error:
ModuleNotFoundError: No module named 'wtforms.fields.html5'
I have in my requirements.txt:
flask
flask-login
flask_sqlalchemy
Flask-Mail
pyodbc
requests
waitress
wtforms
I tried to add flask_WTF but it did not fix it.
Any idea what's going on? I thought of upgrading wtforms but it seems like I have the newest version:
pip install wtforms
Requirement already satisfied: wtforms in /usr/local/lib/python3.9/site-packages (3.0.0)
Requirement already satisfied: MarkupSafe in /usr/local/lib/python3.9/site-packages (from wtforms) (2.0.1)
For WTForms >= 3.0.0, just use wtforms.fields to import these classes, as the html5 module seems to have been retired in 3.0.0a1. So in your case:
from wtforms.fields import DateField, EmailField, TelField
See the WTForms documentation on fields for details (for example for EmailField).
Downgrading WTForms==2.3.3 solved the issue for me. Thread referenced here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With