Haris Hafiz
Haris Hafiz

Reputation: 1

Display datastore entity by ID

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

Upvotes: 0

Views: 79

Answers (1)

Renato Byrro
Renato Byrro

Reputation: 3784

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.

Upvotes: 1

Related Questions