Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

primary key in google appengine datastore

    from google.appengine.ext import db
    from datetime import date    
    class Test(db.Model):
        title=db.StringProperty(required=True)
        tags=db.StringListProperty(required=True)

a print on the Test type of object shows

Test(key_id=1, title='ashu_saved', tags=['db'])

but the key_id attribute is is not accesible by title.key_id.also test.pk returns u'agRibG9nchILEgxhc2lzYWlkX3Rlc3QYAQw' is there a way to obtain nicely looking integer primary keys that i can use in the urls, from the model objects in google-appengine?

like image 852
Bunny Rabbit Avatar asked Nov 21 '10 16:11

Bunny Rabbit


1 Answers

Try with:

yourkey = test.key().id()

and to get your value back:

Test.get_by_id(ids = yourkey)
like image 124
systempuntoout Avatar answered Oct 01 '22 20:10

systempuntoout