-1
我創造了這個形式,這是一個多輸入選項,通過查詢集填充:如何打印Django的形式多次與不同的ID
class TestForm(forms.ModelForm):
field = ModelChoiceField(queryset=TestTable.objects.all().order_by('desc1'))
class Meta(object):
model = BlockValue
fields =()
Whithin相同的HTML表單,我想打印TestForm很多次。
在views.py中可以創建一個TestForm的數組並使用for循環在模板中打印?
是的,爲什麼不嘗試呢? – Sayse
https://docs.djangoproject.com/en/1.9/ref/forms/api/#configuring-html-label-tags搜索auto_id,這會給你想法 –
https://docs.djangoproject.com/en /1.9/topics/forms/modelforms/#model-formsets –