1

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.

1 Answer 1

2

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.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.