code_junkie

about one to many relationship in datastore and dereferncing in google app engine

Nov 13th, 2011
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. class Satellite(db.Model):
  2. name = db.StringProperty()
  3.  
  4. class Channel(db.Model):
  5. satellite = db.ReferenceProperty(Satellite, collection_name='channels')
  6. freq = db.StringProperty()
  7.  
  8. my_sat = Satellite(name='SatCOM1')
  9. my_sat.put()
  10. Channel(satellite=my_sat,freq='28.1200Hz').put()
  11. ... #Add other channels ...
  12.  
  13. for chan in my_sat.channels:
  14. print 'Channel frequency: %s' % (chan.freq)
Add Comment
Please, Sign In to add comment