Implementing HTML CheckBoxes in Jinja

From PeformIQ Upgrade
Revision as of 10:25, 25 December 2014 by PeterHarding (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Notes


Example 1

Template

{% for contact in contacts %}
    <input type="checkbox" id="id_{{contact.id}}" name="contacts" value="{{contact.id}}">
    <label for="id_{{contact.id}}">{{contact.name}}</label>
{% endfor %}


Flask

if request.method == "POST":
    selected_contacts = request.form.getlist("contacts")

Gotchas