Django form.as_p DateField not showing input type as date

前端 未结 7 1257
野性不改
野性不改 2020-12-08 08:45

Working on my first django app, and I have a model defined with some DateFields, and then a ModelForm off of that model i.e.

models

7条回答
  •  轮回少年
    2020-12-08 09:05

    Using the django-widget-tweaks package you can do this pretty simply by using:

    {% load widget_tweaks %}
    {{form.date|attr:"type:date"}}
    

    and making the field a date time field in your class:

    date = forms.DateField()
    

提交回复
热议问题