Custom keys for Google App Engine models (Python)
- by Cameron
First off, I'm relatively new to Google App Engine, so I'm probably doing something silly.
Say I've got a model Foo:
class Foo(db.Model):
name = db.StringProperty()
I want to use name as a unique key for every Foo object. How is this done?
When I want to get a specific Foo object, I currently query the datastore for all Foo objects with the target unique name, but queries are slow (plus it's a pain to ensure that name is unique when each new Foo is created).
There's got to be a better way to do this!
Thanks.