title: Taking Attendance in Django Python
body: <p>I am trying to mark attendance. But I am not able to get the code. My submit should send the input to database for each student. Any suggestion for doing this in better way is welcome.
  My models.py is as follows
  It has Employee, Mentor and Student and below is the model where values can be changed.</p>
  
  <pre><code>class ClassName(models.Model):
   class_name = models.CharField(max_length=20)
   class_date=models.DateField(blank=True, null=True)
   Mentor= models.ForeignKey(Mentor, related_name='class_mentor')
   student = models.ManyToManyField(Student, related_name='class_student')
   attendance = models.BooleanField(default=True)
  
   def __str__(self):
      return str(self.class_name)
  </code></pre>
  
  <p>Views.py : This is just to display the markattendance page. I am not able to figure out how to get the value and Post the value to database. Right now, I am fetching Students value from the Students table. I think I should be creating Classname Form and and display students. I was getting Internal server error.
      def markattendance(request):
       students = Student.objects.all()
       return render(request, 'home/markattendance.html',
                    {'students': students})</p>
  
  <p>markattendance.html : On clicking submit, the attendance should be marked.
  <a href="https://i.stack.imgur.com/W3nZc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/W3nZc.png" alt="enter image description here"></a></p>
  
  <pre><code>{% extends 'home/index.html' %}
  {% block content %}
  
  &lt;div class="container-fluid"&gt;
  
  &lt;div&gt;
  
      &lt;div class="card-body"&gt;
        &lt;div class="table-responsive"&gt;
          &lt;table class="table table-bordered" id="dataTable" width="100%" cellspacing="0"&gt;
            &lt;thead&gt;
              &lt;tr&gt;
                &lt;th&gt;Name&lt;/th&gt;
                &lt;th&gt;Class&lt;/th&gt;
                &lt;th&gt;Attendance&lt;/th&gt;
              &lt;/tr&gt;
            &lt;/thead&gt;
            &lt;tbody&gt;
            {% for students in students %}
            {% ifequal students.Men_name|stringformat:"s" user.username %}
              &lt;tr&gt;
                &lt;td&gt;{{ students.Student_name }}&lt;/td&gt;
                &lt;td&gt;{{ students.Student_Class }}&lt;/td&gt;
                &lt;td&gt;
                      &lt;label class="switch"&gt;
                      &lt;input id="toggle-slider_position()" type="checkbox"&gt;
                      &lt;span class="slider round"&gt;&lt;/span&gt;
                      &lt;/label&gt;
                &lt;/td&gt;
              &lt;/tr&gt;
              {% endifequal %}
            {% endfor %}
            &lt;/tbody&gt;
  
          &lt;/table&gt;
  
  
  
        &lt;/div&gt;
          &lt;br/&gt;
          &lt;div class="row" &gt;
              &lt;div class="col-sm-4"&gt;&lt;/div&gt;
                           &lt;div class='col-sm-4' align="center"&gt;
                              &lt;div class="form-group"&gt;
                                  &lt;div class='input-group date' id='datetimepicker1'&gt;
                                      &lt;input type='text' class="form-control" /&gt;
                                      &lt;span class="input-group-addon"&gt;
                                          &lt;span class="glyphicon glyphicon-calendar"&gt;&lt;/span&gt;
                                      &lt;/span&gt;
                                  &lt;/div&gt;
                              &lt;/div&gt;
                               &lt;button class="btn btn-lg"&gt;Submit&lt;/button&gt;
                          &lt;/div&gt;
                           &lt;div class="col-sm-4"&gt;
  
  
                               &lt;/div&gt;
                      &lt;/div&gt;
          &lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;
      &lt;/div&gt;
  
    &lt;/div&gt;
  &lt;/div&gt;
  {% endblock %}
  </code></pre>
  
  <p>Please help me out. Any suggestion is welcome.</p>