Reputation: 2958
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)
Upvotes: 0
Views: 207
Reputation: 89917
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.
Upvotes: 3