模板
<form method="post" action=".">
{% csrf_token %}
<table width="100%" cellpadding="0" cellspacing="0" >
<tr>
<td colspan="2" class="incident-type">
{% for type in typeList%}
{% if type.parent_type_id == None %}
<h1>{{type.title}}</h1>
{% else %}
{% if checked_ones %}
<label><input type="checkbox" checked="True" value="{{ type.title }}" name="key">{{ type.title }}</label><br />
{% else %}
<label><input type="checkbox" value="{{ type.title }}" name="key">{{ type.title }}</label><br />
{% endif %}
{% endfor %}
请参见此处,复选框输入来自视图.py你知道吗
checked_ones = [unicode(x) for x in subtype if unicode(x) in request.POST.getlist('key')]
这里的问题是,如果选中并保存任何一个选项,那么所有其他复选框选项都会被选中(在页面重定向之后)。你知道吗
尝试了一些逻辑循环,需要一些帮助。你知道吗
试试这个
希望这有帮助!你知道吗
相关问题 更多 >
编程相关推荐