如何从Django表中的值表向视图发送数据

2024-04-19 15:48:28 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在开发django应用程序。我需要将下表中的数据发送到视图。我使用了从db到表的数据,现在我想提交这些带有备注的数据。我还必须使用这个值更新其他一些db表

 <form method="POST">{% csrf_token %}

      <th scope="col">Cheque No</th>
      <th scope="col">Date Created</th>
      <th scope="col">Name</th>

      <th scope="col">Amount</th>
      <th scope="col">Remark</th>
      <th scope="col">Action</th>

    </tr>
  </thead>
  <tbody id="myTable">
          {% for instance in queryset%}
          <tr>

                  <td>{{instance.cheque_no}}<input type='hidden' name='cheque_no' id="cheque_no{{instance.cheque_no}}" value='{{instance.cheque_no}}'><input type='hidden' name='id' value='{{instance.id}}'></td>
                  <td>{{instance.date_created}}<input type='hidden' name='date' value='{{instance.date_created}}'></td>
                  <td>{{instance.contributor_id}}<input type='hidden' name='contributor_id' value='{{instance.contributor_id_id}}'></td>
                  <td>{{instance.total_amount}}<input type='hidden' name='total_amount' value='{{instance.total_amount}}'></td>
                  <td><input type="text" name="remark" class="vTextField form-control" maxlength="20" id="id_remark" ></td>


                  <td>
                          <div class="form-inline">
                                  <div class="form-group mx-sm-3 mb-2">
                      <input type="submit" class="btn btn-primary btn-sm " style="height: 1.8rem; font-size: .85rem;"   role="button" value="Cancel" name='cancel'>
                      <input type="submit" class="btn btn-primary btn-sm " style="margin-left:10px; height: 1.8rem; font-size: .85rem;" value=" View Payment Details"  role="button" href='#'>

                      <!-- <a class="form-control btn btn-primary btn-sm"   role="button" href='/{{instance.lot_seq_no}}/deleteChequelot/'>Delete</a> -->
                                      </div></div>
                  </td>
          </tr>

          {%endfor%}

  </tbody>
</table>
<input type="text" name="remark_all" placeholder="Remark">
<input type="submit" value="Cancel All" name="cancel_all" class='btn btn-primary'>
</form>

Tags: instancenonameformidinputvaluetype