          """
          content = {'text': 'foobar'}
          request = factory.put('/1', json.dumps(content),
                                content_type='application/json')
          response = self.view(request, pk=1).render()
          self.assertEquals(response.status_code, status.HTTP_200_OK)
          self.assertEquals(response.data, {'id': 1, 'text': 'foobar'})
          updated = self.objects.get(id=1)
          self.assertEquals(updated.text, 'foobar')
  
 
</s> remove         # Forward 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)
 </s> add             instance = self.opts.model(**attrs) </s> remove         instance = self.opts.model(**attrs)
 </s> add  </s> remove         # Reverse 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)
 </s> add         else:
            # Reverse 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 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) </s> remove             return instance
 </s> add 
        response = self.view(request, pk='1').render()
          """
          content = {'text': 'foobar'}
          request = factory.put('/1', json.dumps(content),
                                content_type='application/json')
        response = self.view(request, pk='1').render()
          self.assertEquals(response.status_code, status.HTTP_200_OK)
          self.assertEquals(response.data, {'id': 1, 'text': 'foobar'})
          updated = self.objects.get(id=1)
          self.assertEquals(updated.text, 'foobar')
  
keep keep keep keep replace keep keep keep keep keep
 Fix for pks returning as strings when set in pre_save.  Fixes #482. Thanks to @n8agrin for the bug report. 
rest_framework/tests/generics.py