probably at the beach
probably at the beach

Reputation: 15207

python google appengine db.Model add a parent after instance has been constructed

I have some models in my datastore and I wanted to add in a parent relationship as described by the parent keyword in the constructor on this page:

http://code.google.com/appengine/docs/python/datastore/modelclass.html

Is this possible and if so, what would be the cleanest way to do it?

Thanks

Upvotes: 3

Views: 199

Answers (2)

Ken
Ken

Reputation: 1110

Your parent class:

class Parent(db.Model):

Your child class:

class Child(Parent):

edit

If you're looking to update existing data then Wooble is correct.

Upvotes: -2

Wooble
Wooble

Reputation: 89857

You can't; the parent's key path is part of the entity's key, which can't be changed after the entity is in the datastore. You'll need to create a new entity with the same data and the new parent and delete the original entity.

Upvotes: 6

Related Questions