如何从呈现的选择中删除“------”?我以我的模型形式使用:
widgets = {
'event_form': forms.CheckboxSelectMultiple(),
}
在模型中,我有 IntegerField 选项:
EVENT_FORM_CHOICES = (
(1, _(u'aaaa')),
(2, _(u'bbbb')),
(3, _(cccc')),
(4, _(u'dddd')),
(5, _(eeee'))
)
呈现的选择包含 --------- 作为第一个可能的选择。我怎样才能摆脱它?
编辑:我想出的唯一工作方式是(在init方法中):
tmp_choices = self.fields['event_form'].choices
del tmp_choices[0]
self.fields['event_form'].choices = tmp_choices
但这不是很优雅的方式:)