django-select2表单字段是否默认为required = False?

时间:2019-05-16 12:49:01

标签: django jquery-select2 django-select2

我注意到我的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')

0 个答案:

没有答案