Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Django多输入表单_Python_Django_Django Forms - Fatal编程技术网

Python Django多输入表单

Python Django多输入表单,python,django,django-forms,Python,Django,Django Forms,我有一个模板,看起来像: <form method="post" action="{% url ... %}"> {% csrf_token %} <table class="table"> {% for x in X %} <tr> <td>{{ x.name }}</td> <td><input type="checkbox" value="{

我有一个模板,看起来像:

<form method="post" action="{% url ... %}">
{% csrf_token %}
<table class="table">
    {% for x in X %}
        <tr>
            <td>{{ x.name }}</td>
            <td><input type="checkbox" value="{{x.id}}"" /></td>
        </tr>
    {% endfor %}
</table>
</form>

{%csrf_令牌%}
{x%中的x为%x}
{{x.name}

您需要为表单字段指定
CheckBoxMultipleSelect
小部件

例如

参考资料:例如

CUSTOMERTYPE = (
    (u'-', u'-'),
    (u'Single', u'Single Customer'),
    (u'Community', u'Community Change'),
)
CustomerType = forms.ChoiceField(choices=CUSTOMERTYPE)

它有效,但我不能给你的答案打分,我只有11分。谢谢你。@MateiFlorescu很高兴知道这一点。当你得到足够的分数后,你可以再评分。但是,您可以接受这一点作为答案。
CUSTOMERTYPE = (
    (u'-', u'-'),
    (u'Single', u'Single Customer'),
    (u'Community', u'Community Change'),
)
CustomerType = forms.ChoiceField(choices=CUSTOMERTYPE)