我有以下代码:
默认情况下,用户模型将用户名设置为“唯一”和“外键”,如何将电子邮件设置为“唯一”和“外键”?
class UserForm(UserCreationForm):
class Meta:
model = User
fields = ['username', 'email', 'password']
widgets = {
'username': forms.TextInput(),
'email': forms.EmailInput(),
}诚挚的问候,
发布于 2020-06-16 21:43:12
我完全误解了数据库的概念,这是姜戈ForeignKey的正式文档。
发布于 2020-05-24 10:35:01
我不知道情况是否如此。您可以在settings.py集中使用django-allauth。
ACCOUNT_UNIQUE_EMAIL = True
ACCOUNT_AUTHENTICATION_METHOD = Truehttps://django-allauth.readthedocs.io/en/latest/configuration.html
https://stackoverflow.com/questions/61984562
复制相似问题