Advertisement
Guest User

Untitled

a guest
Mar 7th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. class SignUpForm(forms.ModelForm):
  2. confirm_password = forms.CharField(max_length=50)
  3.  
  4. class Meta:
  5. model = User
  6. fields = ['password', 'email', 'first_name', 'last_name']
  7.  
  8. def is_valid(self):
  9. if super(SignUpForm, self).is_valid() and self.confirm_password == self.instance.password:
  10. return True
  11. else:
  12. False
  13.  
  14. def save(self, commit=True):
  15. if self.is_valid():
  16. self.instance.objects.create_user(username=self.instance.email, email=self.instance.email,
  17. password=self.instance.password, first_name=self.first_name,
  18. last_name=self.last_name).save()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement