title: Django many to many field not being saved correctly in database
body: <p>When I try to save many to many field in django. It only save one item , even when I have selected 2 items from the template.</p>
  <p>My views.py looks like this</p>
  <pre><code>@login_required()
  def create_class(request):
      tea_user = request.user.username
      validate = teacher_validation(tea_user)
      if validate:
          if request.method == 'POST':
              Link = request.POST.get('link')
              Subject = request.POST.get('Subject')
              Class = request.POST.getlist('Class')
              print(Class)
              teacher_user = Teacher.objects.get(User=request.user)
              teacher = Teacher.objects.get(id=teacher_user.id)
              created_class = Online_Class.objects.create( Link=Link, Subject=Subject,Created_by =teacher )
              for classes in Class:
                  created_class.Class.set([classes])
              return redirect('home')
          
          return render(request, 'online_class/Teacher/class-create.html')
      else:
          messages.warning(request, 'Sorry You Dont have Permission to access this page')
          return redirect('logout')
  </code></pre>
  <p>My models.py looks like this</p>
  <pre><code>class Online_Class(models.Model):
      Created_by = models.ForeignKey(Teacher, on_delete=models.DO_NOTHING)
      Class = models.ManyToManyField(Classes)
      Subject = models.CharField(max_length=100)
      Link = models.CharField(max_length=200)
      Joined_by = models.ManyToManyField(Student, blank=True)
      created_at = models.DateTimeField(auto_now_add=True)
      choice = (('Yes','Yes'),('No', 'No'))
      Class_Ended = models.CharField(choices=choice, default='No', max_length=10)
  </code></pre>
  <p>My template looks like this</p>
  <pre><code>{% extends 'dashboard/teacher/base.html' %}
  {% block title %} Create Class {% endblock title %}
  {% block class %} active {% endblock class %}
  {% block body %}
  &lt;div class=&quot;pc-container&quot;&gt;
      &lt;div class=&quot;pcoded-content&quot;&gt;
          &lt;div class=&quot;row&quot;&gt;
              &lt;form method=&quot;POST&quot;&gt;
                  {% csrf_token %}
                  &lt;div class=&quot;form-group&quot;&gt;
                      &lt;label &gt;Zoom Link&lt;/label&gt;
                      &lt;input type=&quot;url&quot; class=&quot;form-control&quot;  name=&quot;link&quot; placeholder=&quot;URL&quot; required=&quot;&quot;&gt;
                  &lt;/div&gt;
                  &lt;div class=&quot;form-group&quot;&gt;
                      &lt;label&gt;Subject&lt;/label&gt;
                      &lt;select class=&quot;form-control&quot; name=&quot;Subject&quot; required=&quot;&quot;&gt;
                      {% for subject in teacher.Subject.all %}
                          &lt;option&gt;{{subject}}&lt;/option&gt;
                      {% endfor %}
                      
                      &lt;/select&gt;
                  &lt;/div&gt;
                  &lt;div class=&quot;form-group&quot;&gt;
                      &lt;label &gt;Select Class&lt;/label&gt;
                      &lt;select multiple class=&quot;form-control&quot; name=&quot;Class&quot; required=&quot;&quot;&gt;
                          {% for class in teacher.Class.all %}
                          &lt;option value=&quot;{{class.id}}&quot;&gt;{{class}}&lt;/option&gt;
                          {% endfor %}
                      &lt;/select&gt;
                      &lt;p class=&quot;help-text&quot;&gt;Hold on ctrl to select multiple class in whindow and command in mac&lt;/p&gt;
                  &lt;/div&gt;
                   &lt;button type=&quot;submit&quot; class=&quot;btn btn-primary&quot;&gt;Submit&lt;/button&gt;
              &lt;/form&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  {% endblock %}
  </code></pre>
  <p>Please help me I don't know why but when I select 2 item also it only save 1 item in the many to many field</p>