'Return a document instance corresponding to a given index if
the key is an integer. If the key is a slice, translate its
bounds into a skip and a limit, and return a cloned queryset
with that skip/limit applied. For example:
>>> User.objects[0]
<User: User object>
>>> User.objects[1:3]
[<User: User object>, <User: User object>]'

def __getitem__(self, key):

    queryset = self.clone()
    if isinstance(key, slice):
        queryset._cursor_obj = queryset._cursor[key]
        (queryset._skip, queryset._limit) = (key.start, key.stop)
        if (key.start and key.stop):
            queryset._limit = (key.stop - key.start)
        return queryset
    elif isinstance(key, int):
        if queryset._scalar:
            return queryset._get_scalar(queryset._document._from_son(queryset._cursor[key], _auto_dereference=self._auto_dereference, only_fields=self.only_fields))
        if queryset._as_pymongo:
            return queryset._get_as_pymongo(queryset._cursor[key])
        return queryset._document._from_son(queryset._cursor[key], _auto_dereference=self._auto_dereference, only_fields=self.only_fields)
    raise AttributeError('Provide    a    slice    or    an    integer    index')
