views:

14

answers:

1
+2  Q: 

GAE Query fetch()

I am trying to learn simple operations with the datastore and I am having problems. Can someone help why this is not working?

class Pet(db.Model):
    name = db.StringProperty

pet = Pet(name="Fluffy")

pet.put()

query = Pet.all()

results = query.fetch(limit=5)
print pet.name

When I run this I get

<class 'google.appengine.ext.db.StringProperty'>
+2  A: 

Try changing

name = db.StringProperty

to

name = db.StringProperty()
mepcotterell
Yep, that looks like that's it.
klausbyskov
Yeah, it had more to do with the data model than with fetch()
mepcotterell