Advertisement
Darkolius

Untitled

Mar 27th, 2021
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.77 KB | None | 0 0
  1. from django import forms
  2. from django.contrib.auth.models import User
  3.  
  4. #https://docs.djangoproject.com/en/3.1/ref/forms/widgets/
  5. class SignUpForm(forms.ModelForm):
  6.     password = forms.CharField(label="Password", widget=forms.PasswordInput())
  7.     confirm_password = forms.CharField(label="Confirm password",widget=forms.PasswordInput())
  8.  
  9.     class Meta:
  10.         model = User
  11.         fields = ('first_name', 'last_name')
  12.  
  13.     def clean(self):
  14.         cleaned_data = super(SignUpForm, self).clean()
  15.         password = cleaned_data.get("password")
  16.         confirm_password = cleaned_data.get("confirm_password")
  17.  
  18.         if password != confirm_password:
  19.             raise forms.ValidationError(
  20.                 "password and confirm_password does not match"
  21.             )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement