[Solved]-No difference between PUT and PATCH in Django REST Framework

10👍

If you look at the generated serializer, you’ll find that you don’t have required fields. In that case, PUT and PATCH will have similar behavior.
Would there be any required field, you’d see the difference.

serializer = UserSerializer(instance=user, data={"first_name": "New First"})
print(serializer)                                                                                                                                                                                  

    UserSerializer(data={'first_name': 'New First'}, instance=<User: tester>):
        id = IntegerField(label='ID', read_only=True)
        email = EmailField(allow_blank=True, label='Email address', max_length=254, required=False)
        first_name = CharField(allow_blank=True, max_length=30, required=False)
        last_name = CharField(allow_blank=True, max_length=150, required=False)

Leave a comment