Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Is there a way of doing this?

like image 805
Ian Burris Avatar asked Jun 25 '10 17:06

Ian Burris


1 Answers

Yes, you can use a SelfReferenceProperty

class SomeModel(db.Model):
    prev = db.SelfReferenceProperty()
    next = db.SelfReferenceProperty()
like image 190
Adam Crossland Avatar answered Sep 23 '22 14:09

Adam Crossland