[英]AttributeError: type object 'User' has no attribute 'USERNAME_FIELD'
This is my code.这是我的代码。 I understand that the User class needs USERNAME_FIELD, but I have that, so I am not sure exactly what the issue is.
我知道 User 类需要 USERNAME_FIELD,但我有这个,所以我不确定到底是什么问题。 Any help is greatly appreciated.
任何帮助是极大的赞赏。
# User model
class User(AbstractBaseUser):
# email
email = models.EmailField(
verbose_name='email address',
max_length=255,
unique=True,
)
USERNAME_FIELD = 'email'
REQUIRED_FIELDS = []
# active status
active = models.BooleanField(default=True)
# admin status
admin = models.BooleanField(default=False)
# first name
fname = models.TextField(default="")
# last name
lname = models.TextField(default="")
# what year of graduation
year = models.IntegerField(default = 0)
在 User 模型中添加 username=None 字段。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.