开发者

Google App Engine python Filter "property of property"

Having these models on google app engine:

class开发者_运维知识库 Choice(db.Model):
    poll = db.ReferenceProperty(Poll, collection_name = 'choices' )
    text = db.StringProperty()

class Vote(db.Model):
    choice = db.ReferenceProperty(Choice, collection_name = 'votes' )
    ip = db.StringProperty()
    date = db.DateTimeProperty(auto_now=1)

How do I do this django query?

same_vote = Vote.filter(ip=self.ip, choice__poll=self.choice.poll)


The App Engine datastore isn't capable of doing a query like this, which requires a join. To perform such a query, you'll need to denormalize your data so your Vote entities include information about which Poll they apply to.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜