I created two customized serializers for the user_create and current_user endpoints in Djoser.
I also wanted to have re_password field in user register. But when I add "USER_CREATE_PASSWORD_RETYPE": True
in the settings of Djoser, my serializer for create user doesn't work and default serializer works. Could you tell me where is the problem?
here is my serializer:
from djoser.serializers import UserSerializer as BaseUserSerializer, UserCreateSerializer as BaseUserCreateSerializer
class UserCreateSerializer(BaseUserCreateSerializer):
class Meta(BaseUserCreateSerializer.Meta):
fields = ['id', 'username', 'password', 'email', 'first_name', 'last_name']
class UserSerializer(BaseUserSerializer):
class Meta(BaseUserSerializer.Meta):
fields = ['id', 'username', 'email', 'first_name', 'last_name', 'password']
and here is settings of Djoser:
DJOSER = {
"USER_CREATE_PASSWORD_RETYPE": True,
"SERIALIZERS": {
'user_create': 'core.serializers.UserCreateSerializer',
'current_user': 'core.serializers.UserSerializer',
}
}
Finally I inherited from UserCreatePasswordRetypeSerializer instead of UserCreateSerializer to have both re_password field and my customized serializer.
And also I deleted "USER_CREATE_PASSWORD_RETYPE": True
from settings and it works properly.