SelfReferenceProperty question

2019-07-14 13:30发布

I am trying to use google appengine. I have this model:

def Human(db.Model):
 name = db.StringProperty()
 friends = db.SelfReferenceProperty()

This Human has more than one friend. So, how to handle this with google appengine?

1条回答
smile是对你的礼貌
2楼-- · 2019-07-14 14:16

For simple many-to-many relationships, use a ListProperty with a list of keys.

If you need to store additional metadata, give the model its own relationship, e.g. Friendship.

Examples of both can be found @ http://code.google.com/appengine/articles/modeling.html

查看更多
登录 后发表回答