如何获取GAE的行ID?

How to get GAE's row id?

这是我在 Google App Engine 中的 table:

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 %}

你可以这样获取id:

article.key.id()

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