I have a Model()
called Member
and I'm inserting new entries using Member.get_or_insert(key_name='lipis')
for example.
My question is how can I get a key_name
that I used to insert a n开发者_运维知识库ew entry for a specific member
?
Do you mean how do you then find that record using the key name, or how do you take an entity and find its key name?
To get that record back out of the datastore, do:
myMember = Member.get_by_key_name('lipis')
...if you have the member record and want to get its key name, you can then do:
keyName = myMember.key().name()
You actually use key().name()
:
lipis = Member.get_or_insert(key_name='lipis')
key_name = lipis.key().name()
If it was inserted with a key_name
(and not an id
), that will return it.
精彩评论