JSON indent parameter in Accept header ignored · Issue #4281 · encode/django-rest-framework (original) (raw)
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
).