title: Repeating record using for loop in database
body: <p>in this code am trying to add the student record in the attendance database whenever the student image is captured by the webcam so <strong>name = image name stored</strong> adding that the image name is the same as the studentid stored in Student entity, whenever the detected face name exist in <strong>Name = the list of images name</strong> then it will add the student info to the attendance database.</p>
  <p>The code just works fine but it keeps repeating the records how can I limit it to add the record just once and not repeating it.</p>
  <pre><code>    def markattendance(name):
          for n in Names:
              if name in Names:
                  # print(name, &quot;Exist&quot;)
  
                  # fitches the information related to the detected name
                  attend = Student.objects.filter(student_id=name).values('student_id', 'student_fname', 'student_lname','fk_course_id_id')
                  #print(attend)
  
                  # filter returns a queryset. A queryset isn't a single object, it's a group of objects so it doesn't make sense
                  # to call save() on a queryset. Instead you save each individual object IN the queryset:
                  for object in attend:
                      #print(object)
                      if object.get('student_id') not in attend:
                          # INSERT SQL statement behind the scenes. Django doesn’t hit the database until you explicitly call save().
                          reg = Attendance(student_id=object.get('student_id'),
                                           student_fname=object.get('student_fname'),
                                           student_lname=object.get('student_lname'),
                                           course_id=object.get('fk_course_id_id'))
                          # print(reg)
                          reg.save()
                      else:
                          pass
  </code></pre>