Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/22.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
如何在模板Django中显示MultiSelectField_Django - Fatal编程技术网

如何在模板Django中显示MultiSelectField

如何在模板Django中显示MultiSelectField,django,Django,我的模型中有一个多选字段。我想在我的模板中像下面的复选框一样显示MultiSelectField表单,我希望用户能够选中它们并保存表单 Feature_1 : [ ] Feature_2 : [ ] Feature_3 : [ ] {{form.feature_1}}不显示任何内容。表单的名称为AddCarForm models.py feature_1 = MultiSelectField(choices=feature_1_choice, max_length=100, defaul

我的模型中有一个多选字段。我想在我的模板中像下面的复选框一样显示MultiSelectField表单,我希望用户能够选中它们并保存表单

Feature_1 : [ ] 
Feature_2 : [ ] 
Feature_3 : [ ] 
{{form.feature_1}}不显示任何内容。表单的名称为AddCarForm

models.py

feature_1 = MultiSelectField(choices=feature_1_choice, max_length=100, default='', blank=True)
    feature_2 = MultiSelectField(choices=feature_2_choice, max_length=100, default='', blank=True)
    feature_3 = MultiSelectField(choices=feature_3_choice, max_length=100, default='', blank=True)
    feature_4 = MultiSelectField(choices=feature_4_choice, max_length=100, default='', blank=True)
    feature_5 = MultiSelectField(choices=feature_5_choice, max_length=100, default='', blank=True)
    feature_6 = MultiSelectField(choices=feature_6_choice, max_length=100, default='', blank=True)