views:

255

answers:

1

i have a one to many relationship between two entities the first one is a satellite and the second one is channel and the satellite form returns a satellite name which i want to appear in another html page with the channel data where you can say that this channel is related to that satellite how to make this

+4  A: 

This sounds like a good case for using the ReferenceProperty that is part of the Datastore API of App Engine. Here's an idea to get you started:

class Satellite(db.Model):
  name = db.StringProperty()

class Channel(db.Model):
  satellite = db.ReferenceProperty(Satellite, collection_name='channels')
  freq = db.StringProperty()

With this you can assign channels like so:

my_sat = Satellite(name='SatCOM1')
my_sat.put()
Channel(satellite=my_sat,freq='28.1200Hz').put()
... #Add other channels ...

Then loop through channels for a given Satellite object:

for chan in my_sat.channels: 
  print 'Channel frequency: %s' % (chan.freq)

Anyway, this pretty much follows this article that describes how to model entity relationships in App Engine. Hope this helps.

fuentesjr