              for key, val in attrs.items():
                  setattr(instance, key, val)
  
          else:
              # Reverse fk relations
              for (obj, model) in self.opts.model._meta.get_all_related_objects_with_model():
                  field_name = obj.field.related_query_name()
                  if field_name in attrs:
                      self.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:
                      self.m2m_data[field_name] = attrs.pop(field_name)
  
              # Forward m2m relations
              for field in self.opts.model._meta.many_to_many:
                  if field.name in attrs:
                      self.m2m_data[field.name] = attrs.pop(field.name)
  
              instance = self.opts.model(**attrs)
  
          try:
              instance.full_clean(exclude=self.get_validation_exclusions())
          except ValidationError, err:
 
</s> remove         self.assertEquals(serializer.data, data)
 </s> add         # We shouldn't have saved anything to the db yet since save
        # hasn't been called.
        queryset = ForeignKeyTarget.objects.all()
        new_serializer = ForeignKeyTargetSerializer(queryset)
        expected = [
            {'id': 1, 'name': u'target-1', 'sources': [1, 2, 3]},
            {'id': 2, 'name': u'target-2', 'sources': []},
        ]        
        self.assertEquals(new_serializer.data, expected)
 </s> remove         self.assertEquals(serializer.data, data)
 </s> add  </s> remove         self.assertEquals(serializer.data, data)
 </s> add 
              for key, val in attrs.items():
                  setattr(instance, key, val)
  
          else:

















              instance = self.opts.model(**attrs)
  
          try:
              instance.full_clean(exclude=self.get_validation_exclusions())
          except ValidationError, err:
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
 Don't persist relation changes in ModelSerializer#restore_object() 
rest_framework/serializers.py