views:

34

answers:

1

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)
+3  A: 

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.

Wooble