【问题标题】:Indexing not supported?不支持索引?
【发布时间】:2012-05-01 07:20:26
【问题描述】:

我收到此错误消息:

TypeError: 'City' object does not support indexing

当这是我的模型时:

class City(db.Model):
  region = db.ReferenceProperty()
  name = db.StringProperty()
  image = db.BlobProperty()
  vieworder = db.IntegerProperty()
  areacode = db.IntegerProperty()

这是我的查询

items = Item.all().filter('modified >', timeline).filter('published =',                 True).order('-modified').filter('cities =',city[0].key()).fetch(PAGESIZE + 1)`

你能告诉我应该如何进行查询或模拟我的类定义吗?我使用listproperty(db.Key) 来模拟与引用的关系,我认为我可以像上面的查询一样进行过滤,因为它适用于一个项目。我该怎么办?

【问题讨论】:

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


    【解决方案1】:
    city[0].key()
    

    是你的错误的原因。您可能认为city 是一个列表,但它实际上是一个单独的项目,或者类似的。

    【讨论】:

      猜你喜欢
      • 2022-11-27
      • 2019-08-18
      • 2014-04-23
      • 2019-11-12
      • 2018-10-29
      • 2011-10-26
      • 2017-09-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多