def _method_to_function(method):
    """
    Return a function that when called with any arguments will return another
    function that takes a queryset and calls the given queryset method, passing
    the queryset as the `self` parameter and forwarding along the other arguments.
    """

    def make_queryset_function(*args, **kwargs):
        def queryset_function(queryset):
            return method(queryset, *args, **kwargs)

        return queryset_function

    return make_queryset_function