Look at the following code:
class DateInput(forms.DateInput):
input_type = 'date'
class DiaryForm(forms.ModelForm):
class Meta:
model = models.Diary
fields = ['budget', 'weight', 'note', 'ddate']
widgets = {
'ddate': DateInput(),
}
def __int__(self, *args, **kwargs):
super(DiaryForm, self).__init__(*args, **kwargs)
self.fields['budget'].label = '今日花费(元)'
self.fields['weight'].label = '今日体重(kg)'
self.fields['note'].label = '心情留言'
self.fields['ddate'].label = '日期'
DateInput ()
Date input ()