2017-04-21 73 views
1

当我去的网页set.html在下拉列表是,我得到一个错误builtins.TypeError TypeError: 'int' object is not iterable的Python:类型错误:“诠释”对象未在SelectMultipleField WTForm可迭代

form.responsible以下类型的сontains数据: [(1534, 'None None ([email protected])'), (1535, 'Second Second ([email protected])')]

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=[]) 

回答

0

我改变SelectMultipleFieldSelectField

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