I have two models: Subject and Content. The Subject entity is the parent of the Content entity. For example, Biochemistry (subject) is the parent of intermediate metabolism (content) and nitrogen metabolism (content). I am having trouble querying these in a presentable formation. The goal is an output like: Biochemistry – carb met., nitrogen met., lipid met.; Immunology – innate, adaptive; English – a, b, c, d, etc. In the past I would just make one massive database that contained the information; but I think using the Parent/Child system will make the database more manageable. Any pointers would be greatly appreciated, I don't really know where to go from here.
def get(self):
#Get all the Subjects
subjects = ndb.gql('SELECT __key__ FROM Subject ORDER BY order ASC')
subjectNames = ndb.gql('SELECT name FROM Subject ORDER BY order ASC')
values = {'subjectNames':subjectNames}
#Ancestor query
values['contents'] = []
for s in subjects:
contents = Content.query(ancestor=s).fetch()
values['contents'].extend(contents)
self.response.out.write(template.render('1_home.html',values))