I would like that every time I create a form with django the tag input includes a specific css class (form-control), to do this I have to write in form.py the following code, adding lines for each field:
class InsertItem(forms.ModelForm):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields['name'].widget.attrs.update({'class': 'form-control'})
self.fields['price'].widget.attrs.update({'class': 'form-control'})
Is there a way to force Django to include the css class that I need in every form, without having to write that things for each from and each line?