Flask. sqlalchemy.exc.InterfaceError:

后端 未结 1 1504
离开以前
离开以前 2021-01-23 07:32

I am using QuerySelectField in my forms.py and when submitting it I get the following error:

InterfaceError: (InterfaceError) Error binding para         


        
1条回答
  •  后悔当初
    2021-01-23 08:01

    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()
    

    0 讨论(0)
提交回复
热议问题