Display datastore entity by ID

2 views
Skip to first unread message

Haris Hafiz via StackOverflow

unread,
May 9, 2017, 6:58:07 PM5/9/17
to gcd-stac...@googlegroups.com

i am really new with Google App Engine

I am trying to make a simple blog where the blog visitors can comment.

The entity properties are 'Title' and 'Content'

I managed to grab hold of the datastore ID by using {{post.key.id()}} and past it to another HTML page. The problem is, i am unable to display the content by the ID

For example, i want to display the BlogPost Title:- I tried - The title of the post is {{title.ID()}} The content is {{content.ID()}}

I don't know the actual Syntax for it. May i know the right syntax?

Appreciate your kind help



Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/43647242/display-datastore-entity-by-id

Renato Byrro via StackOverflow

unread,
May 9, 2017, 6:58:09 PM5/9/17
to gcd-stac...@googlegroups.com

Once you have the entity Key, you just need to use get() method to retrieve the entity content from Datastore. In Python, you would do this:

post = post.key.get()

Then you can access the post content as properties of the post object:

post_title = post.title
post_content = post.content

For more info, see the Gogle Datastore CRUD documentation (using Python NDB library). You'll find similar docs there for other languages.



Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/43647242/display-datastore-entity-by-id/43695884#43695884
Reply all
Reply to author
Forward
0 new messages