Question: So I have an model serializer which consists of

```
class UserSerializer(serializers.ModelSerializer):
    class Meta:
        model = User
        fields = ('id', 'name', 'description')

```

This is my ViewSet

```
class UserViewSet(viewsets.ModelViewSet):
    queryset = User.objects.all()
    serializer_class = UserSerializer

```

This is my URLs.py file:

```
from django.conf.urls import include, url
from rest_framework import routers
import views

router = DefaultRouter()
router.register('user', views.UserViewSet)
urlpatterns = [
    url(r'^', include(router.urls)),
    url(r'^login/', include('rest_framework.urls', namespace='rest_framework'))
]

```

Using the serializer, I can make it print out the objects inside my database. If I have the object PK/ID, I want to be able to update the field `id` or `name` of the object. Is there a way I can do that with a patch/post request using the serializer? I'm new to this so I'd love it if someone can help me out with this.

I'm thinking of just doing a `POST` request, then have it do this:

```
user = User.objects.get(id=id)
user.name = "XXXXX"
user.save()

```

But I want to do this using the serializer, using a `PATCH` request.

Answer: 
`StringBuffer` does NOT override `equals()` method. So, it uses the implementation of `Object` class which checks for the reference equality (Checks if both the objects are the **same**).

In your case, both the objects are obviously not the same (though their contents are the same), hence it fails.

`String` on the other hand overrides the `equals()` method and returns `true` if the contents of both the Strings are the same.
Answer is so simple in First Expression

(i) `assertEquals(exp.toString(), orig.toString());` Passing `String` Object as argument. assertEquals is overloaded with `String` Class. So, It will accept it as a `String` and checks the value equality. SO, this will Pass the test.

(ii) `assertTrue(exp, orig);` Here you are passing `StringBuffer` Object as an argument assertEquals is not overloaded with `StringBuffer` Class. So, It will accept it as a `Object` and checks the reference equality not the value. SO, this will raise an Exception during test.

(iii) `assertEquals(exp.equals(orig));` Here you are using `equals` method which actually belongs to Object Class not to `StringBuffer`. . so, Again it will checks the reference equality not the value. SO, this will fail the test coz both object referring to different `Object`.