python - 按年份过滤日期,请帮我找出错误

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

我编写此代码是为了按特定年份过滤日期

class Record(db.Model):
    StartDate = db.DateProperty(required=True)
    Description = db.StringProperty()

    @db.ComputedProperty
    def RequestYear(self):
        return self.StartDate.year

然后我尝试

records = Record.all().filter("RequestYear", 2011)

records = Record.all().filter("RequestYear = ", 2011)

但是记录没有来 self 的数据存储区的任何数据

最佳答案

计算属性实际上存储在数据存储中。如果您在保存原始数据后添加了它,则在更新所有现有实体以包含新数据之前,您将不会获得任何结果 - 您应该能够迭代并重新保存它们。

关于python - 按年份过滤日期,请帮我找出错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8789090/

相关文章:

python - 与多处理并行填充字典

python - 获取 "error: Unable to find vcvarsall.bat"然后 "RuntimeError: autoconf error"试图在 Windows 上安装 pycrypto

python - 谷歌 NDB : Adding an entity with non existing parent

python - 应用引擎 : Maintaining DataStore Consistency When Creating Records

node.js - rxjs 订阅返回重复项

python - 在 python 脚本中将子进程与 openssl 一起使用

python - random.uniform(0,1) 可以生成 0 或 1 吗?

java - 数据存储查询过期的速度有多快?

python - Mechanize 不适用于在 Google Appengine 中自动登录 gmail

python - Google App Engine 模型的 JSON 序列化