              if field_name in attrs:
                  related_data[field_name] = attrs.pop(field_name)
  
          # Reverse m2m relations
          for (obj, model) in self.opts.model._meta.get_all_related_m2m_objects_with_model():
              field_name = obj.field.related_query_name()
              if field_name in attrs:
                  m2m_data[field_name] = attrs.pop(field_name)
  
          # Forward m2m relations
 
</s> remove         # Reverse fk relations
        for (obj, model) in self.opts.model._meta.get_all_related_objects_with_model():
 </s> add         # Reverse fk or one-to-one relations
        for (obj, model) in meta.get_all_related_objects_with_model(): </s> remove         for field in self.opts.model._meta.many_to_many:
 </s> add         for field in meta.many_to_many:
        for (obj, model) in meta.get_all_related_m2m_objects_with_model():
              if field_name in attrs:
                  related_data[field_name] = attrs.pop(field_name)
  
          # Reverse m2m relations
        for (obj, model) in meta.get_all_related_m2m_objects_with_model():
              field_name = obj.field.related_query_name()
              if field_name in attrs:
                  m2m_data[field_name] = attrs.pop(field_name)
  
          # Forward m2m relations
keep keep keep keep replace keep keep keep keep keep
 Clean up and comment `restore_object` 
rest_framework/serializers.py