def _move(self, up, qs=None):
        qs = self.get_ordering_queryset(qs)

        if up:
            qs = qs.order_by('-' + self.order_field_name)\
                   .filter(**{self.order_field_name + '__lt': getattr(self, self.order_field_name)})
        else:
            qs = qs.filter(**{self.order_field_name + '__gt': getattr(self, self.order_field_name)})
        try:
            replacement = qs[0]
        except __HOLE__:
            # already first/last
            return
        order, replacement_order = getattr(self, self.order_field_name), getattr(replacement, self.order_field_name)
        setattr(self, self.order_field_name, replacement_order)
        setattr(replacement, self.order_field_name, order)
        self.save()
        replacement.save()
dataset/ETHPy150Open bfirsh/django-ordered-model/ordered_model/models.py/OrderedModelBase._move