how to convert the string version of a key back into a form that I can use the get() function on to get the entity instance
google-app-engine, google-cloud-datastore
Solution
In case you are using Python NDB, then you can convert a Key to a URL safe string as follows:
key_str = yourmodel.key.urlsafe()
You can convert back from a URL safe string back to Key as follows:
my_key = ndb.Key(urlsafe=key_str)
For more information take a look at NDB Key class
Problem
class Key(encoded=None) A unique key for a Datastore object. A key can be converted to a string by passing the Key object to str(). The string is "urlsafe"—it uses only characters valid for use in URLs. The string representation of the key can be converted back to a Key object by passing it to the Key constructor (the encoded argument). Note: The string representation of a key looks cryptic, but is not encrypted! It can be converted back to the raw key data, both kind and identifier. If you don't want to expose this data to your users (and allow them to easily guess other entities' keys), then encrypt these strings or use something else. encoded The str form of a Key instance to convert back into a Key.