def METHOD_NAME(self, serializer):
    if isinstance(serializer, HyperlinkedModelSerializer):
        return serializer.url_field_name
    elif isinstance(serializer, NoModelSerializer):
        return serializer.get_url_field_name()
    else:
        return None