One-To-Many Example in NDB

后端 未结 4 2001
囚心锁ツ
囚心锁ツ 2021-01-12 08:22

I am trying to create ndb.Model class like Students and subjects

class Subject(ndb.Model):
     name = ndb.StringProperty()

class Student(ndb.Model):
    na         


        
4条回答
  •  借酒劲吻你
    2021-01-12 09:14

    Use the subject as a key.

    me = Student(key_name='KurzedMetal')
    programming = Subject(key_name='Programming')
    programming.put()
    me.subject = programming.key()
    me.put()
    

提交回复
热议问题