1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| class UserSignUpForm(ModelForm):
password = forms.CharField(widget=forms.PasswordInput())
password_confirm = forms.CharField(widget=forms.PasswordInput())
class Meta:
model = User
fields = ['username', 'first_name', 'last_name', 'email', 'password']
widgets = {
'username': TextInput(attrs={'class': 'form-control'}),
'last_name': TextInput(attrs={'class': 'form-control'}),
'first_name': TextInput(attrs={'class': 'form-control'}),
'email': EmailInput(attrs={'class': 'form-control'}),
}
def clean(self):
cleaned_data = super(UserSignUpForm, self).clean()
password = cleaned_data.get('password')
password_confirm = cleaned_data.get('password_confirm')
username = cleaned_data.get('username')
return cleaned_data |