Dessie
Dessie

Reputation: 341

Why can't I access a google app engine entity's key from within my jinja template

This should be a simple one. I am building a google app engine app. It makes a list of forms dyanmically using a list of entities called blocks. The blocks have various properties, the labels on the radio buttons, the size of the text area, that kind of thing. I iterate over a list of these blocks in a jinja template, picking out the particulars of the form from the properties of that particular block. That all works fine.

However, I would like to include a unique identifier for the block entity that I am using to build the form within the form. That will give me an efficient way of knowing what my user is responding to when he sends me a response.

I tried:

<form>
    <input type="hidden" name="qKey" value="{{block.id}}">

That returns the following to my browser:

<form>
    <input type="hidden" name="qKey" value="">

Then I tried:

    <form>
        <input type="hidden" name="qKey" value="{{block.key}}">

That returned:

<form>
    <input type="hidden" name="qKey" value="<bound method Block.key of <dynamicsurvey2.Block object at 0x10a092f10>>">

Any thoughts would be much appreciated.

Upvotes: 1

Views: 723

Answers (1)

Amber
Amber

Reputation: 526533

Jinja2 doesn't automatically call functions for you, and .key() is a function, not a property.

Instead of {{block.key}} you need to use {{block.key()}} to actually call the function and get the return value.

Upvotes: 2

Related Questions