Python: TypeError: 'int' object is not iterable in SelectMultipleField WTForm
Python: TypeError: 'int' object is not iterable in SelectMultipleField WTForm
当我转到下拉菜单所在的页面 set.html
时,出现错误 builtins.TypeError TypeError: 'int' object is not iterable
form.responsible
с包含以下类型的数据:
[(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=[])
我把SelectMultipleField
改成了SelectField
class AssignmentsForm(CSRFForm):
responsible = SelectField(lazy_gettext("Select assignee"), choices=[])
当我转到下拉菜单所在的页面 set.html
时,出现错误 builtins.TypeError TypeError: 'int' object is not iterable
form.responsible
с包含以下类型的数据:
[(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=[])
我把SelectMultipleField
改成了SelectField
class AssignmentsForm(CSRFForm):
responsible = SelectField(lazy_gettext("Select assignee"), choices=[])