def validate(self, attrs):
    'validate and authenticate the user'
    email = attrs.get('email')
    password = attrs.get('password')
    user = authenticate(request=self.context.get('request'), username=email, password=password)
    if (not user):
        msg = _('Unable to authenticate with the provided credentials')
        raise serializers.ValidationError(msg, code='authentication')
    attrs['user'] = user
    return attrs
validate and authenticate the user
def validate(self, attrs):
    
    email = attrs.get('email')
    password = attrs.get('password')
    user = authenticate(request=self.context.get('request'), username=email, password=password)
    if (not user):
        msg = _('Unable to authenticate with the provided credentials')
        raise serializers.ValidationError(msg, code='authentication')
    attrs['user'] = user
    return attrs