'Handle any exception that occurs, by returning an appropriate response,
or re-raising the error.'

def handle_exception(self, exc):

    if isinstance(exc, (exceptions.NotAuthenticated, exceptions.AuthenticationFailed)):
        auth_header = self.get_authenticate_header(self.request)
        if auth_header:
            exc.auth_header = auth_header
        else:
            exc.status_code = status.HTTP_403_FORBIDDEN
    exception_handler = self.get_exception_handler()
    context = self.get_exception_handler_context()
    response = exception_handler(exc, context)
    if (response is None):
        self.raise_uncaught_exception(exc)
    response.exception = True
    return response
