Skip to content

Clearing a ManyToManyField in a multipart PATCH Request #2883

Open
@DavidMuller

Description

@DavidMuller

Hello,

I'm having some trouble clearing a ManyToMany field in a multipart PATCH request.

In a JSON request, I would clear my ManyToMany field, 'many_to_many_field' by PATCHing something like:

{"many_to_many_field": []}

However, in a multipart PATCH request, sending values including '[]', '', 'null', 'None', etc all yield the following error:

["Incorrect type. Expected pk value, received unicode."]

It seems that ManyRelatedField.get_value() does not recognize any of those options as special indicators of empty.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions