我有一个从AbstractUser继承的customerUser,如果用户注册电子邮件aaaa@gmail.com,然后第二次,他试图注册与谷歌登录和相同的电子邮件(aaa@gmail.com)
Django-Alluth是否创建了一个重复的用户,如果是的话,我该如何避免这种情况?
from django.contrib.auth.forms import UserCreationForm, UserChangeForm
from .models import CustomUser
class CustomUserCreationForm(UserCreationForm):
class Meta(UserCreationForm.Meta):
model = CustomUser
fields = (
"username",
"email",
"age",
) # ne
email = {"required": True}
class CustomUserChangeForm(UserChangeForm):
class Meta:
model = CustomUser
fields = (
"username",
"email",
"age",
) # ne
email = {"required": True}
class CustomUser(AbstractUser):
age = models.PositiveIntegerField(null=True, blank=True)
email = models.EmailField(blank=False, null=False)
字符串
1条答案
按热度按时间cuxqih211#
您可以使电子邮件字段唯一以避免这种情况
字符串