def to_link(self, request, instance, urlpattern, kwargs=None, query_kwargs=None):
    'Return an absolute url for the given urlpattern.'
    if query_kwargs:
        query_kwargs = {k: getattr(instance, v) for (k, v) in query_kwargs.items()}
    if (not kwargs):
        url = reverse(urlpattern, request=request)
        if (not query_kwargs):
            return {'href': url}
        return {'href': ('%s?%s' % (url, urlencode(query_kwargs)))}
    if isinstance(kwargs, basestring):
        url = reverse(urlpattern, kwargs={kwargs: getattr(instance, kwargs)}, request=request)
        if (not query_kwargs):
            return {'href': url}
        return {'href': ('%s?%s' % (url, urlencode(query_kwargs)))}
    reverse_kwargs = {}
    if kwargs:
        for (k, v) in kwargs.items():
            reverse_kwargs[k] = getattr(instance, v)
    try:
        url = reverse(urlpattern, kwargs=reverse_kwargs, request=request)
        if (not query_kwargs):
            return {'href': url}
        return {'href': ('%s?%s' % (url, urlencode(query_kwargs)))}
    except NoReverseMatch:
        return None
Return an absolute url for the given urlpattern.
def to_link(self, request, instance, urlpattern, kwargs=None, query_kwargs=None):
    
    if query_kwargs:
        query_kwargs = {k: getattr(instance, v) for (k, v) in query_kwargs.items()}
    if (not kwargs):
        url = reverse(urlpattern, request=request)
        if (not query_kwargs):
            return {'href': url}
        return {'href': ('%s?%s' % (url, urlencode(query_kwargs)))}
    if isinstance(kwargs, basestring):
        url = reverse(urlpattern, kwargs={kwargs: getattr(instance, kwargs)}, request=request)
        if (not query_kwargs):
            return {'href': url}
        return {'href': ('%s?%s' % (url, urlencode(query_kwargs)))}
    reverse_kwargs = {}
    if kwargs:
        for (k, v) in kwargs.items():
            reverse_kwargs[k] = getattr(instance, v)
    try:
        url = reverse(urlpattern, kwargs=reverse_kwargs, request=request)
        if (not query_kwargs):
            return {'href': url}
        return {'href': ('%s?%s' % (url, urlencode(query_kwargs)))}
    except NoReverseMatch:
        return None