Again, my question not only about the PATCH method (there is no problems 
with it).
My question is about the partial model update (or, SQL statement, generated 
by PATCH method)
Example:
model:
class TestModel(models.Model):
    field_a = models.CharField()
    field_b = models.CharField()
    field_c = models.CharField()



serializer:
class TestModelSerializer(serializers.ModelSerializer):
    class Meta:
        model = TestModel


view:
class ModelDetail(generics.RetrieveUpdateAPIView):
    queryset = TestModel.objects.all()
    serializer_class = TestModelSerializer



PATCH request:
{
 "field_a": "Test value"
}



*The SQL, generated:*
SELECT ... FROM `testmodel_table` ... WHERE ...;
UPDATE `testmodel_table` SET `field_a` = 'Test value', `field_b` = 
'some_selected_value', `field_c` = 'some_selected_value' WHERE...;
*But, NOT:* 
UPDATE `testmodel_table` SET `field_a` = 'Test value' WHERE...;

Even with PATCH request, all columns in DB were updated.





On Friday, February 1, 2019 at 9:30:17 PM UTC+2, [email protected] wrote:
>
> Hi, all.
>
> In DRF, it is possible to update only DB fields, specified in "PATCH" 
> request? 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to