如何获得GAE的行ID?

时间:2017-05-14 07:47:23

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

以下是我在Google App Engine中的表格:

class Article:
    title = db.StringProperty(required=True)
    text = db.TextProperty(required=True)
    created = db.DateTimeProperty(auto_now_add=True)

然后我把它渲染到前面:

articles = db.GqlQuery("SELECT * FROM Article ORDER BY created DESC")
self.render("index.html", articles=articles)

我怎样才能得到这一行的id?就像这样:

{% for article in articles %}
{{ article.id }}
{% endfor %}

1 个答案:

答案 0 :(得分:3)

你可以得到这样的id:

article.key.id()

查看Entities, Properties, and Keys上的文档。