One-to-many relationships in datastore

ぐ巨炮叔叔 提交于 2019-12-04 17:49:41

userEmail is not a defined name in the scope of the for loop. What you need is:

for v in scott.venues:
    self.response.out.write(scott.userEmail)
    self.response.out.write(v.venue)

EDIT: Concerning your edit - if your goal is to make a joined query - you can't, not with the google app datastore. However, you can grab the user like this:

query = User.all()
query.filter("userEmail =", "scott@example.com")
results=query.fetch(1)
scott=results[0]

and then get the venues like scott.venues. The relation is defined in the line with db.ReferenceProperty, which defines what is someuser.venues and what is somevenue.user.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!