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
- class SignUpForm(forms.ModelForm):
- username = models.CharField(
- widget=forms.EmailInput(),
- label='Email address',
- required=True,
- max_length=150
- )
- raw_password = models.CharField(widget=forms.PasswordInput(), label='Password', required=True)
- class Meta:
- model = User
- fields = ('username', 'raw_password')
- def save(self, commit=True):
- user = super().save(commit=False)
- raw_password = self.cleaned_data.get('raw_password')
- user.set_password(raw_password)
- if commit:
- user.save()
- return user
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement