Hello,

I am working on to return specific value when validation error occurs. But 
I couldn't receive my error message.

class OwnSerializer(serializers.ModelSerializer):

    class Meta:
        model = Own
        model.domain = serializers.URLField(error_messages={
            "message": "Url cannot be duplicated",
            'error_code': 101,
        })

        fields = ('domain','name')

    def __init__(self, *args, **kwargs):
        super(OwnSerializer, self).__init__(*args, **kwargs)
        self.fields['domain'].error_messages['required'] = 'My custom required 
msg'


I googled and find some solutions. One is to put error_message on target 
field, and other is create error message on __init__. But it both does not 
work on my side. For suer, domain has value 'unique=True' on model.

Does some one knows well about this?

Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to