Child gets deleted when partial via form-urlencoded
Hey guys,
thanks for the great library. I encounter this issue though with the following models:
class ProfileSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = models.Profile
fields = ['gender', 'age', 'date_of_birth', 'language',]
class UserSerializer(NestedUpdateMixin, serializers.HyperlinkedModelSerializer): # ModelSerializer
email = serializers.ReadOnlyField()
gold_bars = serializers.ReadOnlyField(source='vault.gold_bars')
groups = serializers.PrimaryKeyRelatedField(many=True, read_only=True)
profile = ProfileSerializer()
receipts = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='receipt-detail')
class Meta:
model = User
fields = ['url', 'email', 'first_name', 'last_name', 'gold_bars', 'groups', 'profile', 'receipts',]
When I send a raw JSON PATCH request to the UserSerializer for the profile data, it works. But if I send a PATCH request as x-www-form-encoded with eg the keys "profile.language" then the "new" profile object gets returned properly but then deleted afterward straight away.
How can I make the profile object updateable via x-www-form-encoded?
The bug seems to lie in the NestedUpdateMixin.delete_reverse_relations_if_need(). Overwriting the update() function and removing that patched it for now.
I can confirm that I have the same issue.
I am also seeing this behavior