表格.py
class ZergitForm(forms.Form):
zerg_selection = forms.MultipleChoiceField(widget=forms.CheckboxSelectMultiple(),required=False)
视图.py
def feeds(request):
if request.method == 'POST':
zergform = ZergitForm(request.POST)
""""""""
some other logic comes here
""""""""
selection = ZergitForm(zerg_id)
return render(request, 'feed_list.html',{'zerg_selection':zerg_selection})
feed_list.html
{% for feed in selection.zerg_selection %}
<span class="checkbox_select">{{ feed }}</span>
{% endfor %}
问题是它呈现为标签中的复选框列表。<li>
但我需要的是标签内带有复选框的输入字段<span>
。如何在我的应用程序中实现它。