user4812479812
user4812479812

Reputation: 593

How can I add class into all fields of my form?

How can I add class form-control into all fields of my form?

class AddOfferForm(forms.ModelForm):
    def __init__(self, *args, **kwargs):
        super(AddOfferForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_class = 'form-horizontal'
        self.helper.form_method = 'post'

Upvotes: 1

Views: 217

Answers (1)

AKS
AKS

Reputation: 19841

You can use the template pack in crispy forms to bootstrap3 in your settings file:

CRISPY_TEMPLATE_PACK = 'bootstrap3'

And, this will automatically add form-control class to each input control in the form.

Upvotes: 3

Related Questions