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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy