I want to use WTForms to display a form in a table. It looks like TableWidget will do the trick, but the only way to get this to work:
from wtforms import Form, TextField, widgets class User(Form): user = TextField('User') email = TextField('Password') widget = widgets.TableWidget(with_table_tag=False) user = User() print user.widget(user)
This seems weird (part of print user.widget(user) ). According to the documentation, I should be able to say:
class User(Form): user = TextField('User', widget=widgets.TableWidget) email = TextField('Password', widget=widgets.TableWidget) user = User() for form_field in user: print form_field
However, this returns a TypeError: __str__ returned non-string (type TableWidget)
When I replace the user, write:
user = TextField('User') email = TextField('Password')
Then, of course, the WTForms rendering works as expected.
How it works?
source share