WTForms TextField Import#
This page explains How to Fix ImportError: cannot import name ‘TextField’ from ‘wtforms’
👉 New to App-Generator? Sign IN with GitHub or Generate Web Apps in no time (free service).
WTForms is a flexible forms validation and rendering library for Python web development. It can work with whatever web framework and template engine you choose. It supports data validation, CSRF protection, internationalization (I18N).
Error Text#
from wtforms import TextField
>> ImportError: cannot import name 'TextField' from 'wtforms'
The above error occurs when the TextField property is used with [WTForms](https://pypi.org/project/WTForms/) version 3.0 or above because the wtforms.TextField deprecated in favor of wtforms.StringField.
Solution 1#
Replace TextField type with StringField. This solution works with WTForms 3.x and 2.x versions
from wtforms import StringField
// replace all TextField usages with StringField type
Solution 2#
Use the latest stable 2.x version of WTForms
// Use 2.x version
pip install WTForms==2.3.3
Using an older version provides a quick fix for your codebase but is not recommended in the long run.
Links#
👉 New to App-Generator? Join our 10k+ Community using GitHub One-Click SignIN.
👉
Download
products and start fast a new project👉 Bootstrap your startUp, MVP or Legacy project with a custom development sprint