Niklas Rosencrantz
Niklas Rosencrantz

Reputation: 26671

Indexing not supported?

I get this error message:

TypeError: 'City' object does not support indexing

when this is my model:

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

and this is my query

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

Can you tell my how I should make my query or model my class definitions? I use listproperty(db.Key) to model relationships with references and I thought I could filter like the above query since it worked for one item. What should I do?

Upvotes: 1

Views: 661

Answers (1)

Amber
Amber

Reputation: 527328

city[0].key()

is the cause of your error. Chances are you thought city was a list, but it's actually a single item, or some such.

Upvotes: 3

Related Questions