Reputation: 41877
In Google appengine datastore, Is it possible to define both id and key_name for one entry?
The documantation of Key.from_path says that only can define id or key_name for it, so which means that an entry can has id or key_name, right?
Upvotes: 1
Views: 2204
Reputation: 11
The entity ID is part of the key. This can be an arbirary string specified by the app, or it can be generated automatically by the datastore. The API calls an entity ID given by the app a key name, and an entity ID generated by the datastore an ID. An entity has either a key name or an ID, but not both. The ID is populated when the entity object is saved to the datastore for the first time.
Upvotes: 1
Reputation: 24966
No. You can one or the other, but not both.
See http://code.google.com/appengine/docs/python/datastore/entities.html#Kinds_IDs_and_Names
Upvotes: 7