Skip to content

Request does not raise UnsupportedMediaType exception #7818

@Feverfew

Description

@Feverfew

Checklist

  • I have reduced the issue to the simplest possible case.

With the following view:

@api_view(['POST'])
@parser_classes([JSONParser])
def my_view(request):
    request.data['change_me'] = 'MyValue'

By sending a request with Content-Type: multipart/form-data (with at least one key/value pair, if it's empty it still goes through but doesn't trip up weirdly enough) one will observe the following behaviour:
AttributeError at $myViewsURL This QueryDict instance is immutable

What surprises me is that as I've specified the use of only the JSONParser, I should expect request.data to be a dict. I've tried other content-types and they are correctly rejected before parsing, but this one goes through.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions