Django form.as_p DateField not showing input type as date

前端 未结 7 1268
野性不改
野性不改 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:12

    I had errors when I compiled the code. Better use this one:

    from django import forms

    class MyModelForm(forms.ModelForm):
        class Meta:
            model = MyModel
            fields = '__all__'
            widgets = {
                'my_date': forms.DateInput(attrs={'type': 'date'})
            }
    

提交回复
热议问题