I am trying to create ndb.Model class like Students and subjects
class Subject(ndb.Model):
name = ndb.StringProperty()
class Student(ndb.Model):
name = ndb.StringProperty()
subject = ndb.KeyProperty(kind=Subject)
One Student can have many Subjects. How to add and store these in this Model. I could not find any example of it. For String Property .. there is field property i.e. repeat=true
How to achieve this and is there any working example on the web. Sorry if it is duplicate question but I tried with my limited skills to search this forum.
subject = ndb.KeyProperty(kind=Subject,repeated=True)
and then when adding the method..in Student object just add std = Student() sub1 = Subject() sub2 = Subject() sub1.put() sub2.put() std.subject.append(sub1) std.subject.append(sub2) std.put() – Exponible