#Djoser custom serializers not being used.

5 messages · Page 1 of 1 (latest)

naive sage
#

Hi folks, just looking for some help. I'm trying to setup custom validation with Djoser auth for user creation. I just want to add a check in the validation method for email, and raise an exception if exists().
Pretty simple, followed Djoser docs, but when calling /users/ endpoint from frontend, it always users the default serializer,

Settings.
'SERIALIZERS': { 'user_create': 'core.serializers.CustomUserCreateSerializer',}

Serializers
`class CustomUserCreateSerializer(UserCreateSerializer):
class Meta(UserCreateSerializer.Meta):
model = User
fields = ('id', 'email', 'username', 'password')

def validate(self, attrs):
        super().validate(attrs)

        #custom validation here`
olive socket
#

how do you validate which serializer is being used?

naive sage
#

I've tried a simple print() debug inside the custom serializer to check if they are being called. They are not. I'm not sure on how to use a more robust method to check.

mystic narwhal
#

can you show the viewset?

naive sage
#

It will be using the Djoser view.