I have a google database called Main
.
class Main(db.Model):
name = db.StringProperty()
phone = db.StringProperty()
There's another database Photo
which references Main
through a one-to-many relationship.
class Photo(db.Model):
main = db.ReferenceProperty(Main,collection_name='photos')
photo1 = db.StringProperty()
photo2 = db.StringProperty()
I was wondering if anyone knows how to make a dictionary, based on the query of Main
(example shown below):
class Name(webapp.RequestHandler):
def get(self):
names = db.GqlQuery('SELECT * FROM Main WHERE name=:1 LIMIT 1','Alan')
values = {'names':names}
self.response.out.write(template.render('base.html', values))
So the goal of the query above is to find the name 'Alan'. The goal of the query I don't know how to do should be to retrieve photo1
and photo2
(when name='Alan') in the class Photo
and put it into a dictionary.
Thanks in advance for your help!