def to(self, order):
if order is None or self.order == order:<EOL><INDENT>return<EOL><DEDENT>qs = self.get_ordering_queryset()<EOL>if self.order > order:<EOL><INDENT>qs.filter(order__lt=self.order, order__gte=order).update(order=F('<STR_LIT>') + <NUM_LIT:1>)<EOL><DEDENT>else:<EOL><INDENT>qs.filter(order__gt=self.order, order__lte=order).update(order=F('<STR_LIT>') - <NUM_LIT:1>)<EOL><DEDENT>self.order = order<EOL>self.save()<EOL>
Move object to a certain position, updating all affected objects to move accordingly up or down.