0
我正在重新排列SQLAlchemy排序列表中的項目。它在我向前移動項目時有效,例如。位置索引1至5.但從5移至1時不起作用。SQLAlchemy排序列表插入
### DB MODELS
from_brief_position = self.request.dbsession.query\
(BriefPosition).filter_by(brief_id=from_brief_id).one()
to_brief_position = self.request.dbsession.query\
(BriefPosition).filter_by(brief_id=to_brief_id).one()
### INDEX
from_position = from_brief_position.position.index
to_position = to_brief_position.position.index
### INSERT AND REARRANGE
p = from_brief_position.position
book.indexed_content.insert(to_position, p)
book.indexed_content.reorder()
謝謝!