title: How to use update_or_create on django post_save?
body: <pre><code>class StudentsEnrolledSubject(models.Model):
          Students_Enrollment_Records = models.ForeignKey(StudentsEnrollmentRecord, related_name='+',
                                                          on_delete=models.CASCADE, null=True)
          Subject_Section_Teacher = models.ForeignKey(SubjectSectionTeacher, related_name='+', on_delete=models.CASCADE,
                                                      null=True,blank=True)      
  
      @receiver(post_save, sender=StudentsEnrollmentRecord)
              def create(sender, instance, created, *args, **kwargs):
                  teachers = SubjectSectionTeacher.objects.filter(Sections=instance.Section,
                                                                  Education_Levels=instance.Education_Levels,
                                                                  Courses=instance.Courses)
              for each in teachers:
                  if created or teachers.exists():
                      print("if")
                      StudentsEnrolledSubject.objects.create_or_update(
                          pk=each.id,
                          Students_Enrollment_Records=instance,
                          Subject_Section_Teacher=each
  
                      )
  </code></pre>
  
  <p>Inserting data is working perfectly but when I update the <strong>existing data</strong> it creates another record not update </p>
  
  <p>what i tried the solution of mr @ruddra,</p>
  
  <pre><code>            StudentsEnrolledSubject.objects.update_or_create(
                  Students_Enrollment_Records=instance,
                  defaults= {'Subject_Section_Teacher': each}
  
              )
  </code></pre>
  
  <p>it works ! but when i tried to save another record with multiple related data, it only save 1 record.</p>