hakunami
hakunami

Reputation: 2441

Model a kind that reference to itself in google appengine datastore?

I have a model Comments. I want to implement a function that user can comment a comment, and I think it's a one-to-many relation, you know, one comment can have some comments. Then I put

comments = db.ReferenceProperty(Comments,collection_name="comments",required=False)

into my Comments model, but it doesn't work.

Can a model reference to itself in google appengine datastore? Is there any other hint?

Thank you!

Upvotes: 2

Views: 127

Answers (2)

proppy
proppy

Reputation: 10504

Use db.ListProperty(db.Key) for referencing multiple entities as a property.

Upvotes: 3

Wooble
Wooble

Reputation: 89867

Use db.SelfReferenceProperty to model a reference to another instance of the same kind.

Upvotes: 3

Related Questions