I'm trying to add a class to <input> on my form. Following the instructions of the first answer to this question, I added some code into my form's __init__ method. However I got the error displayed in the title.
forms.py
class SignupForm(UserCreationForm):
email = forms.EmailField(max_length=200, help_text='Required')
first_name = forms.CharField(max_length=30)
last_name = forms.CharField(max_length=30)
def __init__(self, *args, **kwargs):
form = super(SignupForm, self).__init__(*args, **kwargs)
for visible in form.visible_fields():
visible.field.widget.attrs['class'] = 'form-control'
class Meta:
model = User
fields = ('username', 'email', 'password1', 'password2', 'first_name', 'last_name',)