Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

PATCH with no data is updating ListField values on ModelSerializer instead of leaving them alone #2761

Closed
Labels
Milestone
@picturedots

Description

@picturedots

I've got a model serializer with two ListFields and an email field in it, something like this

class MySettingsSerializer(ModelSerializer):    location_codes = serializers.ListField(child=serializers.CharField(),         required=False)    permissions = serializers.ListField(child=serializers.CharField(),         required=False )    class Meta:        model = MySettings        fields = ('id', 'email', 'location_codes', 'permissions' )

I've also got a view class that uses UpdateModelMixin to provide an update method.

When I do a PATCH to to my view, the expected behavior is that only the values that are sent will be changed. For example, PATCH with
{"permissions": [ "change_mymodel" ] }
should change the permissions field on the MySettings object, and not change any of the other fields. This works as expected.

However, if I do a PATCH with no data at all, both the permissions and locations_codes are set to empty lists. The other field (email) is not changed, which leads me to believe that there is bug related to identifying if a ListField should be updated during a PATCH.

Note that this issue cannot be triggered by the HTML form interface by PATCHING a {} -- I can only see it by using a client like Postman and doing a PATCH with no content.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp