17

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)
1
  • I just wanted to rebuild my docker container too ! Commented Apr 16, 2022 at 14:04

2 Answers 2

30

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).

8

Downgrading WTForms==2.3.3 solved the issue for me. Thread referenced here.

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.