yezyilomo / django-restql

Turn your API made with Django REST Framework(DRF) into a GraphQL like API.
https://yezyilomo.github.io/django-restql
MIT License
616 stars 43 forks source link

NestedField will not ignored when PATCH #270

Closed caesarleong closed 3 years ago

caesarleong commented 3 years ago

When I using PATCH to update a field y in ModelA, field_x will raising a ValueError exception

class ModelASerializer(DynamicFieldsMixin, serializers.ModelSerializer):
    field_x = NestedField(ModelXSerializer, accept_pk=True)

    class Meta:
        model = ModelA
        fields = '__all__'

PATCH action should just ignore the field which is not in the request payload. Right now I have to add the original value of field_x to workaround this issue.

yezyilomo commented 3 years ago

What version are you using?.

caesarleong commented 3 years ago

What version are you using?.

0.11.0, should try the latest?

yezyilomo commented 3 years ago

You should definitely try the latest version, we've fixed a lot of bugs and introduced lots of features since v0.11.0. You can check the release history here https://github.com/yezyilomo/django-restql/releases. The good thing is all changes we have done since v0.11.0 are backward compatible so migration to the latest version(v0.14.0) should be smooth, basically just installing the new version and you will be good to go.

caesarleong commented 3 years ago

I tested with latest 0.14.0 release, the issue persist. Thanks

yezyilomo commented 3 years ago

Okay, I think you forgot to inherit NestedModelSerializer your issue is similar to #188

caesarleong commented 3 years ago

Yes, you are right, I forget to inherit NestedModelSerializer, and the issue gone once I inherit NestedModelSerializer. Close the issue with thankful