title: Django - Saving multiple selection boxes in one form
body: <p>I need to save multiple selections in one form, but it is not saving the values to my model. This is how the form looks:</p>
  
  <p><a href="https://i.stack.imgur.com/lJ7OH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lJ7OH.png" alt="enter image description here"></a>  </p>
  
  <p>This is my models.py</p>
  
  <pre><code>class ChoiceManager(models.Manager):
      def rates (self, Task_id, rating2, yo):
          assignment = Assignment.objects.get(id=Assignment_id)
          rating = rating2
          yo = FiscalYear.objects.get(fy_year=years)
          for i in range(len(rating2)):
              rated = Prog_capability.objects.create(
              task = task, 
              rating2 = rating[i],
              fy = yo[i]
          )
  
  class NewYear(models.Model):
      year = models.CharField(max_length=5)
      new_year = models.CharField(max_length=5)
  
  class Choice(models.Model):
      rating = models.CharField(max_length=255, blank=True, null=True)
      year = models.ForeignKey(NewYear, related_name="choices")
      assignment = models.ForeignKey(Assignment, related_name="choice")
      objects = ChoiceManager()
  </code></pre>
  
  <p>This is my views.py</p>
  
  <pre><code>def task_rating(request, Assignment_id):
      ratings = request.POST.getlist('rating2',[])
      years= request.POST.getlist('yo",[])
      rates= Choice.objects.rates(Assignment_id, ratings, years)
      return redirect ((reverse('Project:assignment_page', kwargs={'Assignment_id': Assignment_id})))
  </code></pre>
  
  <p>HTML</p>
  
  <pre><code> &lt;form action="{% url 'project:rating' %}" method="post"&gt;
        {% csrf_token %}
        {% for year in years %}
          &lt;li class=cap_select&gt;
            &lt;div id=fyc&gt;{{year.fy_year}}&lt;/div&gt;
            &lt;select name="rating2" id="{{assignment.id}}-{{year.id}}"&gt;
              &lt;option&gt;Choose From List&lt;/option&gt;
              &lt;option class=hi value="high"&gt;High&lt;/option&gt;
              &lt;option class=med value="medium"&gt;Medium&lt;/option&gt;
              &lt;option class=low value="low"&gt;Low&lt;/option&gt;
              &lt;option class=na value="n/a"&gt;N/A&lt;/option&gt;
            &lt;/select&gt; 
            &lt;input type="hidden" name="yo" value={{year.fy_year}}&gt;
          &lt;/li&gt;  
        {% endfor %}
          &lt;br&gt;
          &lt;input id=save_cap type="submit" value="Save"&gt;
        &lt;/form&gt; 
  </code></pre>
  
  <p>I'm getting a </p>
  
  <blockquote>
    <p>"NewYear matching query does not exist." and cannot save the data.</p>
  </blockquote>
  
  <p>I've been on this for a couple of days. Any help will be appreciated. </p>