我正在将 wtforms 字段 ( http://wtforms.simplecodes.com/docs/0.6/fields.html ) 与 <input>
进行比较标签( http://www.w3schools.com/tags/att_input_type.asp )。对于 wtforms 中的某些字段,<input type>
等价物很容易猜到。但对于其他人,我真的不知道如何实现。
是否有任何示例网页可以让我尝试渲染 wtform 字段?或者是否有一些 wtforms 模板集合,以便我可以自己尝试?
最佳答案
只需查看源代码即可轻松找到答案:
# ... snip ...
class SearchField(core.StringField):
"""
Represents an ``<input type="search">``.
"""
widget = widgets.SearchInput()
class TelField(core.StringField):
"""
Represents an ``<input type="tel">``.
"""
widget = widgets.TelInput()
class URLField(core.StringField):
"""
Represents an ``<input type="url">``.
"""
widget = widgets.URLInput()
# ... snip ...
关于python - Flask-wtf 字段渲染示例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14567247/