我使用flask,python,wtforms和wtforms_alchemy
为什么我收到了“无法调用的未绑定字段”错误'
当行data = ModelFormField(fields.FormField(TestRelationForm))
存在时,否则不存在?
from wtforms import fields
from wtforms.ext.sqlalchemy.fields import QuerySelectField
from app import app
from app import db
from app.models import *
ModelForm = model_form_factory(Form)
class TestRelationForm(ModelForm):
class Meta:
model = TestRelation
@classmethod
def get_session():
# this method should return sqlalchemy session
return db.session
class TestForm(ModelForm):
data = ModelFormField(fields.FormField(TestRelationForm))
class Meta:
model = Test
@classmethod
def get_session():
# this method should return sqlalchemy session
return db.session
在我的处理程序中,我调用form = TestForm(),因此表单被实例化......我将实例化传递给主模板,其中包含以下行:return render_template("main.html", form=form)
此时我甚至不关心编辑表单,我只想让测试表单显示来自TestRelationForm的字段,就像它打算做的那样..
答案 0 :(得分:0)
面掌。
这是
f((unsigned short)0)
不
data = ModelFormField(TestRelationForm)