Flask. sqlalchemy.exc.InterfaceError: <app.models.Menu object at 0x7f287026dd10>

强颜欢笑 提交于 2019-12-02 05:12:02

Finally the issue is solved after hours of googling. the issue was about QuerySelectField. The problems was that when retrieving form.parent_id.data it actually returned a query object, whie I need a string vaue. So I converted the value to string and added submitted it to database:

a = str(form.parent_id.data)

if form.validate_on_submit():
        new_menu = Menu(
            form.title.data,
            form.title_eng.data,
            form.alias.data,
            form.menu_type.data,
            form.ordering.data,
            form.check_out_time.data,
            form.access.data,
            form.published.data,
            a, #form.parent_id.data,
            form.image.data,
            form.content.data,
            form.content_eng.data,
            form.metades.data,
            form.metakey.data)
        form.populate_obj(new_menu)
        db.session.add(new_menu)
        db.session.commit()
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!