表格.py
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)
模板.py
{% for radio in SettingsForm.date_format %}
{{ radio.choice_label }}
<div class="select">{{ radio.tag }}</div>
{% endfor %}
追溯
Template error:
In template /root/Projects/ir/templates/incident/date_format.html, error at line 107
Caught TypeError while rendering: 'BoundField' object is not iterable
97 : <tr>
98 : <td style="width:200px;">
99 :
100 : {{ SettingsForm.date_format }}
101 : {% for radio in form.date_format %}
102 :
103 : <div >{{ radio }}</div>
104 : {% endfor %}
105 : </td>
106 : <td>eg 21 / 01 / 2014 <br />
107 : {% for date in SettingsForm.time_format %}
108 : {{ date.label_tag }}
109 : {{ date }}
110 : {% endfor %}
113 : </tr>
Traceback:
File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
111. response = callback(request, *callback_args, **callback_kwargs)
File "/root/Projects/ir/incident/views.py" in date_format
796. context_instance=RequestContext(request))
File "/usr/lib/python2.7/site-packages/django/shortcuts/__init__.py" in render_to_response
20. return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs)
File "/usr/lib/python2.7/site-packages/django/template/loader.py" in render_to_string
188. return t.render(context_instance)
File "/usr/lib/python2.7/site-packages/django/template/base.py" in render
123. return self._render(context)
File "/usr/lib/python2.7/site-packages/django/template/base.py" in _render
117. return self.nodelist.render(context)
File "/usr/lib/python2.7/site-packages/django/template/base.py" in render
744. bits.append(self.render_node(node, context))
File "/usr/lib/python2.7/site-packages/django/template/debug.py" in render_node
73. result = node.render(context)
File "/usr/lib/python2.7/site-packages/django/template/loader_tags.py" in render
127. return compiled_parent._render(context)
File "/usr/lib/python2.7/site-packages/django/template/base.py" in _render
117. return self.nodelist.render(context)
File "/usr/lib/python2.7/site-packages/django/template/base.py" in render
744. bits.append(self.render_node(node, context))
File "/usr/lib/python2.7/site-packages/django/template/debug.py" in render_node
73. result = node.render(context)
File "/usr/lib/python2.7/site-packages/django/template/loader_tags.py" in render
127. return compiled_parent._render(context)
File "/usr/lib/python2.7/site-packages/django/template/base.py" in _render
117. return self.nodelist.render(context)
File "/usr/lib/python2.7/site-packages/django/template/base.py" in render
744. bits.append(self.render_node(node, context))
File "/usr/lib/python2.7/site-packages/django/template/debug.py" in render_node
73. result = node.render(context)
File "/usr/lib/python2.7/site-packages/django/template/loader_tags.py" in render
127. return compiled_parent._render(context)
File "/usr/lib/python2.7/site-packages/django/template/base.py" in _render
117. return self.nodelist.render(context)
File "/usr/lib/python2.7/site-packages/django/template/base.py" in render
744. bits.append(self.render_node(node, context))
File "/usr/lib/python2.7/site-packages/django/template/debug.py" in render_node
73. result = node.render(context)
File "/usr/lib/python2.7/site-packages/django/template/loader_tags.py" in render
64. result = block.nodelist.render(context)
File "/usr/lib/python2.7/site-packages/django/template/base.py" in render
744. bits.append(self.render_node(node, context))
File "/usr/lib/python2.7/site-packages/django/template/debug.py" in render_node
73. result = node.render(context)
File "/usr/lib/python2.7/site-packages/django/template/defaulttags.py" in render
190. values = list(values)
Exception Type: TemplateSyntaxError at /member/date-format/
Exception Value: Caught TypeError while rendering: 'BoundField' object is not iterable
我正在使用 django 1.3.7。
由于单选按钮呈现在无序列表中,因此我使用了单选按钮自定义。
我在自定义单选按钮时收到此错误。
更新:
通常,如果我呈现一个单选按钮,将呈现在页面中的列表中。如果我希望它在没有该列表格式的情况下显示,即没有项目符号点。如何使用 css 或任何其他技术
谢谢