我注意到我的select2字段在HTML中没有required
属性?根据Django的form
文档,默认required
值为True
。知道select2是否默认为False
吗?
class CustomFroalaEditor(FroalaEditor):
def __init__(self, *args, **kwargs):
super(CustomFroalaEditor, self).__init__(*args, **kwargs)
def render(self, name, value, attrs=None, renderer=None):
html = super(FroalaEditor, self).render(name, value, attrs)
return mark_safe(html)
class NewBlaForm(forms.ModelForm):
company = forms.ChoiceField(widget=forms.Select(attrs={'id': 'nbc__name-dropdown', 'class': 'form-control'}))
product = forms.ChoiceField(widget=forms.Select(attrs={'id': 'nbp__name-dropdown', 'class': 'form-control', 'disabled': 'disabled'}))
class Meta:
model = Bla
fields = ('product')