def querysetmethod(func):
    """
    Decorator for a model method to make it apply to the queryset.

    Will be accessible as model.objects.all().foo()

    "self" will then be the query object.

    """
    func._querysetmethod = True
    return func