我正在尝试使用django-rest-auth
的自定义寄存器序列化程序。
用户应用的名称为myapp.users
,序列化程序文件位于该应用中。
在序列化程序文件中我有:
class CustomRegisterSerializer(RegisterSerializer):
和settings.py
:
REST_AUTH_REGISTER_SERIALIZERS = {
"REGISTER_SERIALIZER": 'myapp.users.serializers.CustomRegisterSerializer'
}
但是这个错误不断发生:
AttributeError: module 'myapp.users.serializers.CustomRegisterSerializer' has no attribute 'CustomRegisterSerializer'
编辑1:
在设置中安装了应用
THIRD_PARTY_APPS = [
'crispy_forms', # Form layouts
'allauth', # registration
'allauth.account', # registration
'allauth.socialaccount', # registration
'rest_framework', #api
'rest_auth.registration',
'rest_framework.authtoken',
'rest_auth',
'corsheaders',
'rest_framework_tracking',
]
LOCAL_APPS = [
# custom users app
'myapp.users.apps.UsersConfig',
]
INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS
编辑2: 来自django.apps导入AppConfig
class UsersConfig(AppConfig):
name = 'myapp.users'
verbose_name = "Users"
你认为我错过了什么?