TaleLin / lin-cms-flask

🎀A simple and practical CMS implememted by Flask
http://doc.cms.talelin.com/
Other
829 stars 215 forks source link

0.2.x falsk 处理 数据新增后 直接返回或者间接查询返回都会 会报错 no attribut '_fields' #156

Closed hezygo closed 2 years ago

hezygo commented 3 years ago

请详细描述您对本项目的任何问题,我们会在第一时间查阅和解决。 image

sunlin92 commented 3 years ago

感谢反馈,这里的设计考虑不周,导致出现了此类问题。请尝试使用以下代码:

    item = KGNode.create(**node_info, commit=True)
    item.init_on_load()
    return jsonify(item)
hezygo commented 3 years ago

感谢反馈,这里的设计考虑不周,导致出现了此类问题。请尝试使用以下代码:

    item = KGNode.create(**node_info, commit=True)
    item.init_on_load()
    return jsonify(item)

使用后 上面那种 能够正确序列化,但是数据为null 下面这种 能够正确序列化且有数据。

    item_ = KGNode.create(**node_info, commit=True)
    item = KGNode.get(Id=item_.id)
    item.init_on_load()
    return jsonify(item)