【发布时间】:2010-10-28 10:31:52
【问题描述】:
我正在使用 Google App Engine(和 Python)构建应用。我有两个关于从数据存储区检索数据的问题。
我有关于用户的信息和关于用户发布的帖子的信息。这是 DB 模型的一部分:
class User(db.Model):
country = db.StringProperty()
# many other entities
class Post(db.Model):
author = db.ReferenceProperty(User)
# many other entities
我想检索某个国家/地区的用户发布的帖子。我是这样尝试的:
posts_query = Post.all().filter(' author.country == ', country)
posts = posts_query.fetch(limit = 100)
但此查询不返回任何结果(国家/地区变量的值存在于数据存储中)。我需要在我的查询中更正什么,这样才能正常工作?
第二个问题:如果帖子数未知(并且可能 > 100),我如何(在给定情况下)从数据存储中检索所有帖子?
提前致谢,
-skazy
【问题讨论】:
标签: python google-app-engine google-cloud-datastore