wtf-sqlalchemy modelform AttributeError:“ str”对象没有属性“ data”

时间:2019-09-16 07:15:38

标签: flask flask-sqlalchemy flask-wtforms

我有一个一对一的关系模型,当我从模板的address_form获取字段“ name”时,它仅以字符串形式显示“ address_form”,而以html显示输入标签。

class AddressForm(ModelForm):
    class Meta:
        model = Address
        include = ['name', 'phone', 'address', 'zip_code']

class EmployeesForm(ModelForm):
    class Meta:
        model = Employee
        include = ['name', 'birthday']
    address_form = ModelFormField(AddressForm)

和在模板中

{{form.employee_form.name}}

在浏览器中打印此“ employee_form”

但是奇怪的是

{{form.name}}

使用html打印输入标签

0 个答案:

没有答案