title: Django - Update operation on nester serialized object (Many to Many)
body: <p>I want to update a nester serializer field, below example i want to update the field <strong>teacher_date</strong></p>
  
  <p>Here is my patch call with data </p>
  
  <pre><code>    {
          "user": {
              "pk": 2,
              "username": "rayees",
              "email": "rayees.xxxx@xxxx.co.in",
              "first_name": "Rayees",
              "last_name": "xxxxx",
              "user_type": "Teacher"
          },
          "first_name": "Rayees",
          "last_name": "xxxx",
          "bio": "TEST BIO",
          "teacher_cost": "22.00",
          "subject": [
              "HINDI",
              "ENGLISH"
          ],
          "teacher_date": [
              {
                  "day_available": "MON",
                  "time_available": "Morning"
              },
              {
                  "day_available": "SUN",
                  "time_available": "Morning"
              }
          ],
          "cities": [
              "SANTA CLARA",
              "SUNNYVALE"
          ]
      }
  </code></pre>
  
  <p>In this example everything get updated except <strong>teacher_date</strong></p>
  
  <p><strong>Model.py</strong></p>
  
  <pre><code>class Availability(models.Model):
      uid = models.AutoField(verbose_name='ID', 
                                    serialize=False, 
                                    auto_created=True, 
                                    primary_key=True)
      MONDAY = 'MON'
      TUESDAY = 'TUE'
      WEDNESDAY = "WED"
      THURSDAY = "THU"
      FRIDAY = 'FRI'
      SATURDAY = "SAT"
      SUNDAY = "SUN"
      DAY = (
          (MONDAY, 'Monday'),
          (TUESDAY, 'Tuesday'),
          (WEDNESDAY, 'Wednesday'),
          (THURSDAY, 'Thursday'),
          (FRIDAY, 'Friday'),
          (SATURDAY, 'Saturday'),
          (SUNDAY, 'Sunday'),
      )
      day_available = models.CharField(
          max_length=3, choices=DAY, default=MONDAY)
  
      MORNING = 'Morning'
      NOON = 'AfterNoon'
      EVENING = 'Evening'
      TIME = (
          (MORNING, 'Morning'),
          (NOON, 'Afternoon'),
          (EVENING, 'Evening'),
      )
  
      time_available = models.CharField(
          max_length=30, choices=TIME, default=MORNING)
  
      def __str__(self):
          return f"{self.day_available} {self.time_available}"
  
  
  class Teacher(models.Model):
      uid = models.AutoField(verbose_name='ID', 
                                    serialize=False, 
                                    auto_created=True, 
                                    primary_key=True)
      user = models.OneToOneField(User, on_delete=models.CASCADE)
      bio = models.TextField(null=True, blank=True)
      teacher_cost = models.DecimalField(
          max_digits=5, decimal_places=2, null=True, blank=True)
      languages = models.CharField(
          max_length=50, null=True, blank=True)
  
      subject = models.ManyToManyField('Subject')
      teacher_date = models.ManyToManyField(Availability)
      cities = models.ManyToManyField('City', related_name='teacher')
  
      def __str__(self):
          return self.user.username
  
  </code></pre>
  
  <p><strong>serializer.py</strong> </p>
  
  <pre><code>class AvailabilityDetails(serializers.ModelSerializer):
      class Meta:
          model = Availability
          fields = ('day_available', 'time_available',)
  
  class TeacherProfileDetails(serializers.ModelSerializer):
      logger = logging.getLogger(__name__)
      teacher_date = AvailabilityDetails(many=True, read_only=True)
      first_name = serializers.CharField(source='user.first_name', read_only=True)
      last_name = serializers.CharField(source='user.last_name', read_only=True)
      cities = serializers.SlugRelatedField(many=True, slug_field='city', queryset=City.objects.all(),)
      subject = serializers.SlugRelatedField(many=True, slug_field='subject', queryset=Subject.objects.all(),)
      teacher_date = AvailabilityDetails(many=True)
      user = UserDetailsSerializer(read_only=True)
  
      class Meta:
          model = Teacher
          fields = ('user', 'first_name', 'last_name', 
                    'bio', 'teacher_cost', 'subject', 'teacher_date', 'cities')
  
      def update(self, instance, validated_data):
          self.logger.info("-------- Inside the update --------------")
          teacher_date = validated_data.pop('teacher_date')
          self.logger.info(teacher_date)
          teacher_date = instance
          teacher_date.__dict__.update(validated_data)
          teacher_date.save()
          return teacher_date
  </code></pre>
  
  <p>Here I am doing some mistake in serialization, for teacher_date,  update method getting called during patch operation, but newly added values are not getting updated in DB </p>