我已将 FloppyForms SplitDateTimeWidget 添加到我的日期时间字段中,如果已经存储了一个值,则时间在表单中按预期正确设置,但日期只是显示为dd/mm/yyyy
.
为了让表单正确设置日期值,我缺少什么?
# forms.py
from django import forms
from generic.forms.widgets.floppyforms import SplitDateTimeWidget
from consoles.models import Event
class EventForm(forms.ModelForm):
class Meta:
model = Event
exclude = ('slug',)
widgets = {
'qualifying_date': SplitDateTimeWidget(date_format='%d/%m/%Y'),
}
生成的 HTML 具有正确的 value 属性,但小部件仅显示 'dd/mm/yyyy'
<input type="date" name="start_0" value="21/08/2014" id="id_start_0">
<input type="time" name="start_1" value="10:00:00" id="id_start_1">