Newbie App Engine Datastore question - Models and .filter()
I am currently testing GAE and I am having some trouble adapting to the datastore ...
Given the example model:
class Category(db.Model):
name = db.StringProperty()
date_time = db.DateProperty(auto_now_add=True)
开发者_JS百科
class Link(db.Model):
category = db.ReferenceProperty(Category, collection_name='links')
name = db.StringProperty()
date_time = db.DateProperty(auto_now_add=True)
link = db.LinkProperty()
type = db.StringProperty(choices=set(["in", "out"]))
and the not working code:
category = Category.get(key)
link = category.links.filter('type=', 'in').get()
it seems that I am unable to filter() on the referenced property... Strange thing is that category.links is a Query object... It is possible to iterate through category.links and verify the type property but I am certain that there is a better way...
Any help is welcome Thanks in advance
Your code is fine, just put a space between type
and =
link = category.links.filter('type =', 'in').get()
精彩评论