Как выполнить итерацию по форме в Html, сохранить данные в переменной в Json, отправить их обратно в Django Backend как POST-данные

Мне нужно выполнить итерации по Html-форме и получить данные в виде JSON obj и отправить их на бэкенд Django, чтобы получить данные в виде objects.all(). Возможно ли это?

В этой форме я итерирую список деталей студента, который я отобразил в шаблоне с помощью Django.

моя форма

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

  <table class="table table-striped">
    <thead>
      <tr>
        <th scope="col">Admission No</th>
        <th scope="col">First Name</th>
        <th scope="col">Last Name</th>
        <th scope="col">Present Status</th>
      </tr>
    </thead>
    <tbody>
      {% for student in student_names %}
      <tr>
        <th scope="row">
          <div class="form-group ">

            <select class="form-control st" style="appearance: none;" id="admission_number" name="admission_number">
              <option>{{student.admission_number}}</option>
            </select>
          </div>
        </th>
        <td>
          <div class="form-group">

            <select class="form-control st" style="appearance: none;" id="first_name" name="first_name">
              <option>{{student.first_name}}</option>
            </select>

          </div>
        </td>
        <td>
          <div class="form-group">

            <select class="form-control st" style="appearance: none;" id="last_name" name="last_name">
              <option>{{student.last_name}}</option>
            </select>

          </div>
        </td>

        <td>
          <div class="form-group">
            <select class="form-control st " style="text-align: center;" id="attendance" name="attendance">
              <option>Yes</option>
              <option>No</option>
            </select>
          </div>
        </td>
      </tr>
      {% endfor %}
    </tbody>
  </table>
  </div>
  </div>

  <div class="row">
    <div class="form-group col-md-4">
      <label for="birthdaytime">Grade :</label>
      <select class="form-control" style="appearance: none; font-size: 18px; font-weight: 500;" id="grade" name="grade">
        <option>{{user.studying_grade}}</option>
      </select>
    </div>

    <div class="form-group col-md-4">
      <label for="birthdaytime">Subject :</label>
      <select class="form-control" style="appearance: none; font-size: 18px; font-weight: 500;" id="subject" name="subject">
        <option>{{user.assigned_subject}}</option>
      </select>
    </div>
    <div class="form-group col-md-4">

    </div>
    <button type="submit" class="btn btn-primary btn-lg btn-block">Submit</button>
  </div>
</form>

любая помощь или предложения, учебники очень ценны, как это сделать... Спасибо

Вернуться на верх