DateField 不呈现为 type="date" [英] DateField is not rendered as type="date"
本文介绍了DateField 不呈现为 type="date"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
class Form(Form):
plan_start = DateField('Plan Start', validators=[Required()])
此代码将呈现此 html.
this code will render this html.
<input id="plan_start" name="plan_start" type="text" value="">
我的问题是:为什么类型是 text
而不是 date
?
My question is: why the type is text
and not date
?
我只能通过在模板中显式传递 type='date'
来解决这个问题.
I only can get this resolved by passing explicitly the type='date'
in template.
{% raw form.plan_start.label %}{% raw form.plan_start(type='date') %}
推荐答案
您可以使用 html5 中的 DateField.
You can use the DateField from html5.
from wtforms.fields.html5 import DateField
class Form(Form):
plan_start = DateField('Plan Start', validators=[Required()])
这篇关于DateField 不呈现为 type="date"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文