python 2.7 - How do I print a specific field from an App Engine Search API document in a jinja2 template? -
i using google app engine search api (in python) , want able print specific search_document fields in jinja2 template. using notation in template try print "comment" field of search document:
{{ scored_document.comment }}
i want output:
test
but instead getting output:
[search.textfield(name=u'comment', value=u'test')]
what correct syntax getting value of "comment"?
the api documentation seems indicate can @ value through .fields
member (a list object), notation doesn't seem work either:
{{ scored_document.fields.comment }}
i extending search api sample provided google on github:
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <link rel="stylesheet" type="text/css" href="/static/css/main.css"/> <title>search demonstration app</title> </head> <body style="margin:20px;"> <form action="/sign" method="post"> <div>search demo</div> <div><textarea name="search" rows="1" cols="60"></textarea></div> <div><input type="submit" value="search"/></div> <div><textarea name="content" rows="3" cols="60"></textarea></div> <div><input type="submit" value="comment"/></div> </form> {{number_returned}} of {{results.number_found}} comments found <p> {% scored_document in results %} <!-- want **value** of comment here: --> {{ scored_document.comment }} <p> {% endfor %} <a href="{{ url }}">{{ url_linktext }}</a> </body> </html>
you want 'value' property of field:
{{ scored_document.comment.value }}
Comments
Post a Comment