I want to create a simple dictionary on the datastore. So I tried created my Entity class like so
class Word(ndb.Model):
id = ndb.KeyProperty(required=True)
definition = ndb.StringProperty(required=True)
Where id is the actual word. The thing is when I try to add an entity, I get an error that e.g. “love” is not a key. So I changed to the following
class Word(ndb.Model):
id = ndb.StringProperty(required=True)
definition = ndb.StringProperty(required=True)
The problem with this new approach is that my id field isn’t viewed as the actual ID of the Entity. The data store creates my id field plus another Name/ID field. How do I use custom ID on App-Engine?
And here is how I’m adding words:
word = Word()
word.id = “love”
word.definition =“a profoundly tender, passionate affection for another person. ”
word.put()
I am hoping not to have to use this NamedModel recommendation but rather something similar to this short one, except with my structured model class.