我正在使用Django Allauth SignupForm。它工作正常,但是当我向其中添加error_css_class='error'
时,如果该字段无效,则不会添加class='error'
。我该怎么做,以便在出现错误时像在forms.Forms
中一样添加类名?
class RegisterForm(SignupForm):
field_order = ['username', 'email', 'password']
error_css_class = 'error'
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields['email'].label = "Email"
self.fields['username'].widget = forms.TextInput(attrs={"placeholder": ""})
self.fields['email'].widget = forms.EmailInput(attrs={"placeholder": ""})
self.fields['password1'].widget = forms.PasswordInput(attrs={"placeholder": ""})