Nyambaa
Nyambaa

Reputation: 41877

appengine datastore id and key_name

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

Answers (2)

magoarcano
magoarcano

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

Dave W. Smith
Dave W. Smith

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

Related Questions