How to get ID field in App Engine datastore?

Say I have a blog on Google AppEngine and you want to print the identifier of each post via jinja2.

blog = db.GqlQuery('SELECT * FROM Blog') self.render('blog.html', blog = blog) 

and in the template:

 {{% for b in blog %}} {{b.id}} {{% endfor %}} 

Now I have not added the "id" field to my database model, I just want to access the assembly in the data warehouse identifier field. How to do it?

+4
source share
1 answer

Look at the db key class. When you have an entity that you can do:

 entity.key().id_or_name() 

or in NDB:

 entity.key.id() 
+9
source

All Articles