我正在尝试使用 rest-auth 提供的序列化程序从定义的端点/rest-auth/user/获取(*带有标头)用户详细信息
(*带有标头(内容类型:application/json 授权:令牌 1a5472b2af03fc0e9de31fc0fc6dd81583087523))
我得到以下回溯:https ://dpaste.de/oYay#L
我已经定义了自定义用户模型(使用电子邮件而不是用户名),如下所示:
class UserManager(BaseUserManager):
def create_user(self, email, password, **kwargs):
user = self.model(
# lower-cases the host name of the email address
# (everything right of the @) to avoid case clashes
email=self.normalize_email(email),
is_active=True,
**kwargs
)
user.set_password(password)
user.save(using=self._db)
return user
def create_superuser(self, email, password, **kwargs):
user = self.model(
email=email,
is_staff=True,
is_superuser=True,
is_active=True,
**kwargs
)
user.set_password(password)
user.save(using=self._db)
return user
class MyUser(AbstractBaseUser, PermissionsMixin):
USERNAME_FIELD = 'email'
email = models.EmailField(unique=True)
设置如下:
AUTH_USER_MODEL = 'users.MyUser'
ACCOUNT_USER_MODEL_USERNAME_FIELD = None
# Config to make the registration email only
ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_UNIQUE_EMAIL = True
ACCOUNT_EMAIL_VERIFICATION = 'optional'
ACCOUNT_USERNAME_REQUIRED = False
ACCOUNT_AUTHENTICATION_METHOD = 'email'
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
不知道如何纠正这个错误..以便它符合 rest-auth 序列化程序。