次のコードを見てください。
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()
日付入力()