如何检索和显示从 GQL 查询返回的多个结果的键?
主文件
class MainPage(webapp2.RequestHandler):
def get(self):
author = "William Shakespeare"
q = db.GqlQuery("SELECT * FROM Book " +
"WHERE author = :1 ", author)
keys = q.Key
template_values = {
'author': author,
'key': key,
}
template = jinja_environment.get_template('index.html')
self.response.out.write(template.render(template_values))
更新 1:
当我使用
keys = q.key()
我收到此错误:
文件“C:\programming_google_app_engine_repo\datastore\main.py”,第 17 行,在 get key = q.key() AttributeError: 'GqlQuery' object has no attribute 'key'