Skip to content

JSON indent parameter in Accept header ignored  #4281

@nealtodd

Description

@nealtodd

Refactoring between 3.3.3 and 3.4.0 changed how Response.render passes media_type to its renderer.

Response sets it as media_type = renderer.media_type compared to self.accepted_media_type (set via APIView.finalize_response here).

Since renderer.media_type looses the indent parameter (i.e. application/json; indent=4 becomes application/json), the resulting JSON rendering is not indented.

A 'simple' fix is to restore the 3.3.3 code where media_type = getattr(self, 'accepted_media_type', None) but I haven't made a PR yet because I'm not clear as to whether there was a specific reason for changing to renderer.media_type (which might have overlooked that it doesn't include indent).

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