def METHOD_NAME(self, obj, view_name, request, format):
    # Unsaved objects will not yet have a valid URL.
    if hasattr(obj, 'pk') and obj.pk in (None, ''):
        return None
    kwargs = {}
    for (
        lookup_url_kwarg,
        lookup_field,
    ) in self.lookup_field_mapping.items():
        kwargs[lookup_url_kwarg] = getattr(obj, lookup_field)
    return self.reverse(
        view_name,
        kwargs=kwargs,
        request=request,
        format=format,
    )