Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from django import forms
- from django.contrib.auth.models import User
- #https://docs.djangoproject.com/en/3.1/ref/forms/widgets/
- class SignUpForm(forms.ModelForm):
- password = forms.CharField(label="Password", widget=forms.PasswordInput())
- confirm_password = forms.CharField(label="Confirm password",widget=forms.PasswordInput())
- class Meta:
- model = User
- fields = ('first_name', 'last_name')
- def clean(self):
- cleaned_data = super(SignUpForm, self).clean()
- password = cleaned_data.get("password")
- confirm_password = cleaned_data.get("confirm_password")
- if password != confirm_password:
- raise forms.ValidationError(
- "password and confirm_password does not match"
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement