Re: Customize serializer errors with incorrect data

2022-08-04 Thread Ammar Mohammed
Hello Sencer You can add cuatom functions to your serializer to return the data with the zerializer . For example you can add : def email_serializer(email): if !email.endswith("gmail.com"): raise SerializerError("Error wrong email address : ", email) This is just an example your functions

Re: Customize serializer errors with incorrect data

2022-08-04 Thread Sencer Hamarat
Hello again, For anyone interested, more detailed version was sent to stackoverflow: https://stackoverflow.com/questions/73231297/proper-way-to-return-erroneous-data-with-serializer-error Kind regards, Sencer HAMARAT On Wed, Aug 3, 2022 at 7:58 AM Sencer Hamarat wrote: > Hi, > > I found a wa

Customize serializer errors with incorrect data

2022-08-02 Thread Sencer Hamarat
Hi, I found a way to customize error messages of the serializer by adding extra_kwargs into the serializer meta class. But, I'm wishing to render custom serializer errors with the incorrect data. For example: class CreateUserSerializer(serializer.ModelSerializer): class Meta: model =