0
<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 %}
看到这里,复选框,输入从该行获得的views.py
checked_ones = [unicode(x) for x in subtype if unicode(x) in request.POST.getlist('key')]
这里的问题是,如果选项中的任何一个被检查并保存,所有其他复选框选项都被选中(在页面重定向之后)。
尝试了一些逻辑循环,需要一些帮助。
是的,它工作正常...感谢僧侣 – user2086641