Custom keys for Google App Engine models (Python)
Posted
by Cameron
on Stack Overflow
See other posts from Stack Overflow
or by Cameron
Published on 2010-03-17T20:34:22Z
Indexed on
2010/04/03
5:23 UTC
Read the original article
Hit count: 232
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.
© Stack Overflow or respective owner