使用Django模板显示input text
。
但是view
只有request.POST
的输入存在于POST
中。动态创建的输入在<form class="form-horizontal" method="post" enctype='multipart/form-data' id="subscription-form">
....
....
<tbody class="draggable-column">
{% for product in products %}
<tr>
<td class="hidden-xs">{{forloop.counter}}</td>
<td class="hidden-xs">{{product.title}}</td>
<td class="hidden-xs">{{product.weight}}</td>
<td class="" >{{product.yearly_consumption}}</td>
<td><input type="text" id="{{product.id}}_jan" data-id="{{product.id}}_jan" class="user-action"></td>
<td><input type="text" id="{{product.id}}_feb" data-id="{{product.id}}_feb" class="user-action"></td>
<td><input type="text" id="{{product.id}}_mar" data-id="{{product.id}}_mar" class="user-action"></td>
......
......
<td><input type="text" id="{{product.id}}_total" data-id="{{product.id}}_total" readonly="readonly" class="total-quantity"></td>
</tr>
<input type="hidden" value="{{product.weight}}" id="{{product.id}}_weight">
<input type="hidden" value="{{product.is_winter}}" id="{{product.id}}_winter">
{% endfor %}
</tbody>
....
....
</form>
。
的test.html
{
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::123ACCNO4567:root"
},
"Action": "sts:AssumeRole",
"Condition": {
"Bool": {
"aws:MultiFactorAuthPresent": "true"
}
}
}
]
}
此表输入在django视图的POST中无法使用。
如何在POST中提供此功能?
答案 0 :(得分:2)
您需要提及每个name attribute
input tags
<tr>
<td class="hidden-xs">{{forloop.counter}}</td>
<td class="hidden-xs">{{product.title}}</td>
<td class="hidden-xs">{{product.weight}}</td>
<td class="" >{{product.yearly_consumption}}</td>
<td><input type="text" id="{{product.id}}_jan" data-id="{{product.id}}_jan" name="{{product.id}}_jan" class="user-action"></td>
<td><input type="text" id="{{product.id}}_feb" data-id="{{product.id}}_feb" name="{{product.id}}_feb" class="user-action"></td>
<td><input type="text" id="{{product.id}}_mar" data-id="{{product.id}}_mar" name="{{product.id}}_mar" class="user-action"></td>
<td><input type="text" id="{{product.id}}_total" data-id="{{product.id}}_total" name= "{{product.id}}_total" readonly="readonly" class="total-quantity"></td>
</tr>
<input type="hidden" value="{{product.weight}}" id="{{product.id}}_weight" name="{{product.id}}_weight" >
<input type="hidden" value="{{product.is_winter}}" id="{{product.id}}_winter" name="{{product.id}}_winter">
{% endfor %}
或者提供适合您目的的任何名称