比如我已经用session的query查询出TestModel了,查询出了所有的结果 all()
返回的结果集放到一个list(TestList)。
其中TestModel有一个属性是Name, 我在遍历TestList时,读取属性Name,会提示
Exception Instance <TestModel at 0x2675433ff28> is not bound to a Session;
attribute refresh operation cannot proceed
那么各位是怎么处理的呢?
해결되었지만 약간 혼란스럽습니다.
해결책은 모델에 __repr__ 메소드를 추가하는 것입니다