How to set a style class to a choice field in a Django form

Viewed 6131

I am trying to set a bootstrap-select class to my choice field. However, I am getting a 'TypeError: init() got an unexpected keyword argument 'attrs''.

class constraintListForm1(forms.Form):

    region = forms.ChoiceField(choices=REGION, required=True)   
    operator = forms.ChoiceField(choices=OPERATOR, required=True )

    class META:
        model = constraintListModel1  


        widgets = {
            'region': forms.ChoiceField(attrs={'class' : 'bootstrap-select'}),


            }
2 Answers
Related