title: How to use Get List from POST Data - Django
body: <p>i hope the title is enough to know what is my problem</p>
  
  <p><a href="https://i.stack.imgur.com/3O2Cx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3O2Cx.png" alt="enter image description here"></a></p>
  
  <p>This is my code in html </p>
  
  <p>when I tried to save this to my database only the "6" is save just like in the picture</p>
  
  <p><a href="https://i.stack.imgur.com/i4UJB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/i4UJB.png" alt="enter image description here"></a></p>
  
  <p>I use jquery to generate the date and textbox to input the grade</p>
  
  <p>this is my html</p>
  
  <pre><code>&lt;table  id="blacklistgrid" border="2px"&gt;
        &lt;tr&gt;
            &lt;th id="th"&gt;Students Name&lt;/th&gt;
            &lt;th data-id='headers' id='header'&gt;Average&lt;/th&gt;
        &lt;/tr&gt;
        {% for student in teacherStudents %}
        &lt;tr class="tr2"&gt;
            &lt;td class="td" &gt;&lt;input type="text" name="students" value="{{student.id}}" id="student" &gt;{{student.Students_Enrollment_Records.Student_Users}}&lt;/td&gt;
             &lt;td data-id='row' id="ans"&gt;&lt;input type='number' class='averages'  readonly/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        {% endfor %}
  &lt;/table&gt;
  
  &lt;script&gt;
       var counter = 0;
      function doTheInsert(){
  
          let header=$("tr#tr");  // same as $.find("tr[id='tr2']")
          $('#th').after("&lt;th data-id='headers' id='header'&gt;&lt;input type='date' name='date'&gt;&lt;/th&gt;");
          var rows=$(".tr2");
          $("&lt;td data-id='row' &gt;&lt;input type='number' name='gradeko' class='average' /&gt;&lt;/td&gt;").insertAfter(".td");
          counter++;
      }
      &lt;/script&gt;
  </code></pre>
  
  <p>this is my views.py</p>
  
  <pre><code>for gradeko in request.POST.get('gradeko'):
      pass
  
  for students in request.POST.getlist('students'):
      studentss = StudentsEnrolledSubject(id=students)
      date = request.POST.getlist('date')
  
      V_insert_data = studentsEnrolledSubjectsGrade(
          Teacher=teacher,
          Students_Enrollment_Records=studentss,
          Date=date,
          Grade=gradeko
      )
      V_insert_data.save()
  </code></pre>
  
  <p>this is my model.py</p>
  
  <pre><code>class studentsEnrolledSubjectsGrade(models.Model):
      Teacher = models.ForeignKey(EmployeeUser, related_name='+', on_delete=models.CASCADE,
                                                  null=True,blank=True)
      Subjects = models.ForeignKey(Subject, related_name='+', on_delete=models.CASCADE, null=True)
      Students_Enrollment_Records = models.ForeignKey(StudentsEnrolledSubject, related_name='+',on_delete=models.CASCADE, null=True)
      Grading_Categories = models.ForeignKey(gradingCategories, related_name='+', on_delete=models.CASCADE,
                                                  null=True,blank=True)
      Date = models.DateField(null=True, blank=True)
      Grade = models.FloatField(null=True, blank=True)
  </code></pre>
  
  <p>what i tried</p>
  
  <pre><code>global gradekos, dates
      for gradeko in request.POST.getlist('gradeko'):
      gradekos = gradeko
      pass
      print(gradekos)
  for date in request.POST.getlist('date'):
      dates = date
      pass
  for students in request.POST.getlist('students'):
      studentss = StudentsEnrolledSubject(id=students)
      #date = request.POST.get('date')
  
      V_insert_data = studentsEnrolledSubjectsGrade(
          Teacher=teacher,
          Students_Enrollment_Records=studentss,
          Date=dates,
          Grade=gradekos
      )
      V_insert_data.save()
  </code></pre>
  
  <p><strong>UPDATE</strong>
  when i tried two dates, only 1 date save in the database</p>
  
  <p><a href="https://i.stack.imgur.com/ompmU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ompmU.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/dSybY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dSybY.png" alt="enter image description here"></a></p>
  
  <p>for example</p>
  
  <p><a href="https://i.stack.imgur.com/SfaGk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SfaGk.png" alt="enter image description here"></a></p>
  
  <p>this is what I want result</p>
  
  <p><a href="https://i.stack.imgur.com/PzFvh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PzFvh.png" alt="enter image description here"></a></p>
  
  <p>this is the actual result</p>
  
  <p><a href="https://i.stack.imgur.com/0L57Q.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0L57Q.png" alt="enter image description here"></a></p>