Advertisement
Darkolius

Untitled

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