def METHOD_NAME(self, obj, view_name, request, format): # pylint: disable=redefined-builtin
    # Unsaved objects will not have a valid URL.
    if hasattr(obj, 'pk') and obj.pk in (None, ''):
        return None
    # get lookup map (will use properties lookup_map and view)
    lookup_map = self._lookup_map
    # pylint: disable-next=unnecessary-lambda-assignment
    get = lambda x: x(obj) if callable(x) else get_attribute(obj, x.split('.'))
    # build kwargs for reverse
    try:
        kwargs = dict((
            (key, get(source)) for (key, source) in lookup_map.items()
        ))
    except (KeyError, AttributeError) as exc:
        raise ValueError(
            "Got {exc_type} when attempting to create url for field "
            "`{field}` on serializer `{serializer}`. "
            "The serializer field lookup_map might be configured incorrectly. "
            "We used `{instance}` instance with lookup map `{lookup_map}`. "
            "Original exception text was: {exc}.".format(
                exc_type=type(exc).__name__,
                field=self.field_name,
                serializer=self.parent.__class__.__name__,
                instance=obj.__class__.__name__,
                lookup_map=lookup_map,
                exc=exc,
            )
        ) from exc
    try:
        return self.reverse(self.view_name, kwargs=kwargs, request=request, format=format)
    except NoReverseMatch as exc:
        raise ImproperlyConfigured(
            # pylint: disable-next=unused-format-string-argument
            "Could not resolve URL for hyperlinked relationship in field "
            "`{field}` on serializer `{serializer}`. "
            "You may have failed to include the related model in your API, "
            "or incorrectly configured `view_name` or `lookup_map` "
            "attribute on this field. Original error: {exc}".format(
                field=self.field_name,
                view_name=self.view_name,
                serializer=self.parent.__class__.__name__,
                kwargs=kwargs,
                exc=exc,
            )
        ) from exc