我有一个带有两个标准字段的Django表单:
empty_layer_name = forms.CharField(max_length=255, required=True, label="Name of new Layer")
GEOM_TYPE = (
('MULTIPOINT', 'Points'),
('MULTILINESTRING', 'Lines'),
('MULTIPOLYGON', 'Polygons')
)
geom_type = forms.ChoiceField(choices=GEOM_TYPE, required=True, label="Type of Data")
另外我在def__init__函数中构建一个Django表单如下:
...
for index in range(int(extra_fields)):
self.fields['extra_field_{index}'.format(index=index)] = forms.CharField(min_length=3, max_length=15)
self.fields['field_type_{index}'.format(index=index)] = forms.ChoiceField(choices=FIELD_TYPE)
我想要的是将生成的字段值打印到同一行。
我想在迭代表单字段时,我需要在我的模板中执行此操作:
{% for field in form_empty_layer.visible_fields %}
{{ field | as_bootstrap }}
{% endfor %}
问题是如何将两个生成的字段放在同一行?