当登录工作正常时,我无法进行 sigup
from django import forms
from django.contrib.auth.models import User
from django.core.exceptions import ValidationError
class UserForm(forms.ModelForm):
password=forms.CharField(widget=forms.PasswordInput)
class Meta:
model=User
fields=['first_name', 'last_name',
'email', 'username',
'password']
label={
'password':'Password'
}
def clean_email(self):
if self.cleaned_data['email'].endswith('@gmail.com')
return self.cleaned_data['email']
else:
raise ValidationError("error")
def save(self):
password=self.cleaned_data.pop('password')
u=super().save()
u.set_password(password)
u.save()
return u
项目链接- https://github.com/tsuryaa/my_project/
慕桂英546537
阿波罗的战车
相关分类