def item_move(self, request, tree_id, item_id, direction):
current_item = MODEL_TREE_ITEM_CLASS._default_manager.get(pk=item_id)<EOL>if direction == '<STR_LIT>':<EOL><INDENT>sort_order = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>sort_order = '<STR_LIT>'<EOL><DEDENT>siblings = MODEL_TREE_ITEM_CLASS._default_manager.filter(<EOL>parent=current_item.parent,<EOL>tree=current_item.tree<EOL>).order_by(sort_order)<EOL>previous_item = None<EOL>for item in siblings:<EOL><INDENT>if item != current_item:<EOL><INDENT>previous_item = item<EOL><DEDENT>else:<EOL><INDENT>break<EOL><DEDENT><DEDENT>if previous_item is not None:<EOL><INDENT>current_item_sort_order = current_item.sort_order<EOL>previous_item_sort_order = previous_item.sort_order<EOL>current_item.sort_order = previous_item_sort_order<EOL>previous_item.sort_order = current_item_sort_order<EOL>current_item.save()<EOL>previous_item.save()<EOL><DEDENT>return HttpResponseRedirect('<STR_LIT>')<EOL>
Moves item up or down by swapping 'sort_order' field values of neighboring items.