flask渲染模板时报错TypeError: 'UnboundField' object is not callable

渲染模板时,访问页面提示TypeError: 'UnboundField' object is not callable

检查代码,发现实例化表单类是,没有加括号:form = NewNoteForm,加了括号后就解决了form = NewNoteForm()

@app.route('/index')
def index():
form = NewNoteForm
notes = Note.query.all()
return render_template('index.html', notes=notes, form=form)

猜你喜欢

转载自www.cnblogs.com/xiaxiaoxu/p/10581522.html