views:

269

answers:

1

I try to get data from app engine datastore.

Filtering query by 'title' (or any other property) works:

obj = db.Query(PageModel).filter('title',title)[0]

But the same thing with ID - doesn't:

obj = db.Query(PageModel).filter('ID',page_id)[0]

I think there is something special about IDs and KEYs in datastore, but I cant find, how to implement getting data by ID.

+3  A: 

Try

obj = PageModel.get_by_id(page_id)

instead. This assumes that the ID you're working with is the numerical ID of a datastore key (ie, came from something like obj.key().id()) and not some arbitrary ID field you've added to your PageModel.

Will McCutchen