def __init__(self, queryset, step=1000, limit=None, min_id=None, max_id=None, sorted=True,
                 select_related=[], callbacks=[]):
        # Support for slicing
        if queryset.query.low_mark == 0 and not\
          (queryset.query.order_by or queryset.query.extra_order_by):
            if limit is None:
                limit = queryset.query.high_mark
            queryset.query.clear_limits()
        else:
            raise InvalidQuerySetError

        self.limit = limit
        if limit:
            self.step = min(limit, abs(step))
            self.desc = step < 0
        else:
            self.step = abs(step)
            self.desc = step < 0
        self.queryset = queryset
        self.min_id, self.max_id = min_id, max_id
        # if max_id isnt set we sort by default for optimization
        self.sorted = sorted or not max_id
        self.select_related = select_related
        self.callbacks = callbacks
dataset/ETHPy150Open disqus/django-db-utils/dbutils/querysets.py/RangeQuerySetWrapper.__init__/original