【问题标题】:How to get GAE's row id?如何获取 GAE 的行 ID?
【发布时间】:2017-10-13 04:20:40
【问题描述】:

这是我在 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 %}

【问题讨论】:

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


    【解决方案1】:

    你可以这样获取id:

    article.key.id()
    

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

    【讨论】:

      猜你喜欢
      • 2016-02-17
      • 2011-12-17
      • 1970-01-01
      • 2011-06-28
      • 2015-03-01
      • 1970-01-01
      • 2016-05-15
      • 2013-03-06
      • 2023-02-09
      相关资源
      最近更新 更多