Rather split this:
widget=forms.TextInput(attrs={"class": required + "digits", 
                                             required: ""}))
Also, please use string formatting rather than +, i.e. "class": "%sdigits" % required.
Also Jonathan's comment about the class name.