Django form.as_p DateField not showing input type as date

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

    There's no need to subclass DateInput.

    class MyModelForm(forms.ModelForm):
        class Meta:
            model = MyModel
            fields = '__all__'
            widgets = {
                'my_date': DateInput(attrs={'type': 'date'})
            }
    
    0 讨论(0)
提交回复
热议问题