本文介绍了如何在Django中渲染不带UL的单选按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Date_Format = (
('0', ' dd / mm / yyyy'),
('1', 'mm / dd / yyyy'),
)
Time_Format = (
('0', ' 12 hour AM / PM '),
('1', ' 24 hour '),
)
class SettingsForm(forms.ModelForm):
date_format = forms.ChoiceField(widget=forms.RadioSelect(), choices=Date_Format)
time_format = forms.ChoiceField(widget=forms.RadioSelect(), choices=Time_Format)
template.py
更新:
template.py
Update:
{% for radio in SettingsForm.date_format %}
{{ radio.choice_label }}
<div class="select">{{ radio.tag }}</div>
{% endfor %}
上面的表单将单选按钮呈现在无序列表中,但我要列出无序的清单。如何执行此操作?
The above form is rendering the radio buttons in a unordered list, but I want to be with out unordered list. How can I perform this?
推荐答案
您可以遍历 RadioSelect
在模板中
{% for choice in form.date_format %}
{{ choice.choice_label }}
<div class="select">{{ choice.tag }}</div> {# Or any other type you want. #}
{% endfor %}
这篇关于如何在Django中渲染不带UL的单选按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!