使用ReferencePropertyField()创建的下拉菜单中的值不正确

时间:2013-04-29 11:52:50

标签: python google-app-engine flask google-cloud-datastore

我在App Engine上使用Flask。这是代码:

models.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)

forms.py:

class TestForm(wtf.Form):

    name = wtf.TextField(description=u"Enter name")
    member = ReferencePropertyField(reference_class=Client)

views.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 __(),根据帖子here它应该有效,但它对我不起作用。

0 个答案:

没有答案