Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DateField is not rendered as type="date"

class Form(Form):
      plan_start = DateField('Plan Start', validators=[Required()]) 

this code will render this html.

<input id="plan_start" name="plan_start" type="text" value="">

My question is: why the type is text and not 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') %}
like image 583
anvd Avatar asked Oct 25 '13 11:10

anvd


1 Answers

You can use the DateField from html5.

from wtforms.fields.html5 import DateField


class Form(Form):
    plan_start = DateField('Plan Start', validators=[Required()])
like image 146
snahor Avatar answered Oct 15 '22 00:10

snahor