我在 App Engine 上使用 Flask。这是代码:
模型.py:
class Client(db.Model):
name = db.StringProperty(required=True)
def __repr__(self):
return unicode(self.name)
class Team(db.Model):
name = db.StringProperty()
member = db.ReferenceProperty(Client)
表格.py:
class TestForm(wtf.Form):
name = wtf.TextField(description=u"Enter name")
member = ReferencePropertyField(reference_class=Client)
视图.py:
@app.route('/test_app/')
def test_app():
form = TestForm()
return render_template("test_app.html", form=form)
模板正在正确呈现,但下拉菜单中的值如下所示:
<select id="member" name="member"><option value="agxzfnRpY2stdHJhY2tyDAsSBkNsaWVudBgEDA">agxzfnRpY2stdHJhY2tyDAsSBkNsaWVudBgEDA</option></select>
在models.py的Client类下还定义了__repr__(),根据这里的帖子它应该可以工作,但它对我不起作用。