craftApprentice
craftApprentice

Reputation: 2777

How to render a query result as checkboxes in GAE Jinja2?

I want to put a button on my application that allows users to query a specific name in the datastore. When user clicks to submit the query, the query result appears as a list of checkboxes (or radiobuttons), allowing user to select one of the results. What is the best way to do this in Jinja2 GAE Python?

Thanks in advance for any help!

Upvotes: 2

Views: 981

Answers (2)

craftApprentice
craftApprentice

Reputation: 2777

I got what I was asking for doing this:

<!DOCTYPE html>

<html>
  <head>
    <title>Search results</title>
    <style type="text/css">
      .label {text-align: right}
      .error {color: red}
    </style>

  </head>

  <body>
    <h2>Search results</h2>
    <form method="post">

{% for p in persons %}

<input type="radio" name="person" value="{{p}}"/> {{p}}

<br>

{% endfor %}

      <input type="submit" value="Choose">
    </form>
  </body>

</html>

Upvotes: 1

Shay Erlichmen
Shay Erlichmen

Reputation: 31928

Jinja2 doesn't have a build in web forms support, but you can use WTForm or Django with it do generate forms.

Upvotes: 0

Related Questions