Q:

AttributeError: 'NoneType' object has no attribute 'visible_fields'

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',)

A:

You get the error because the super() call returns None. Inside the __init__ method you can access the form's attributes with with self.
def __init__(self, *args, **kwargs):
    super(SignupForm, self).__init__(*args, **kwargs)
    for visible in self.visible_fields():
        ...

