Python:TypeError:'int'对象在SelectMultipleField WTForm中不可迭代

时间:2017-04-21 06:48:52

标签: python python-3.x flask wtforms

当我转到下拉列表的set.html页面时,出现错误builtins.TypeError TypeError: 'int' object is not iterable

form.responsibleсontains以下类型的数据: [(1534, 'None None (qa@app.com)'), (1535, 'Second Second (qa2@app.com)')]

view.py

current_permission = Permissions.query.all()
users = []
for user in current_permission:
    receivers = user.group.users.all()
    for user in receivers:
        users.append(user)

if is_group_manager or assignee_from_unmanaged_group:
    form.responsible.choices = [
        (user.id, "{0} ({1})".format(user.details.full_name, user.email))for user in users

set.html

{% block page_block_content %}
    <form method="POST">
        {{ form.csrf_token }}
        {{ wtf.form_field(form.responsible, class="form-control select2") }}
{% endblock %}

form.py

class AssignmentsForm(CSRFForm):
    responsible = SelectMultipleField(lazy_gettext("Select assignee"), choices=[])

1 个答案:

答案 0 :(得分:0)

我将SelectMultipleField更改为SelectField

class AssignmentsForm(CSRFForm):
    responsible = SelectField(lazy_gettext("Select assignee"), choices=[])