开发者

Creating a model that references itself with Google App Engine

I tried doing the following

class SomeModel(db.Model):
    prev = db.ReferenceProperty(SomeModel)
    next = db.ReferenceProperty(SomeModel)

but got the following error

NameError: name 'TrackPointModel' is not defined

I开发者_如何学JAVAs there a way of doing this?


Yes, you can use a SelfReferenceProperty

class SomeModel(db.Model):
    prev = db.SelfReferenceProperty()
    next = db.SelfReferenceProperty()


Doesn't having a, say, next property make the prev property superfluous? If I'm not mistaken this works equally well:

class SomeModel(db.Model):
    next = db.SelfReferenceProperty(collection_name='prev')
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜