Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#32646 closed New feature (duplicate)

add request.json() shortcut

Reported by: Collin Anderson Owned by: nobody
Component: HTTP handling Version: 4.0
Severity: Normal Keywords:
Cc: Adam Johnson Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

It would be nice to have a request.json() shortcut.

Change History (5)

comment:2 by Mariusz Felisiak, 4 years ago

Resolution: duplicate
Status: newclosed

As far as I'm aware, it's a duplicate of #27415.

comment:3 by Carlton Gibson, 4 years ago

Cc: Adam Johnson added

I think this also relates to #32259. Completing the content negotiation story as suggested on #27415 would be the significant benefits justifying changes in #32259. 🤔

comment:4 by Adam Johnson, 4 years ago

There's also #21442 for Tom Christie's work.

I think adding request.json() would be a bit of a mis-feature, when we could instead add request.data with a parsing framework that's more "future-proof". It would be based on DRF's behaviour, so would be familiar to most Django devs already.

comment:5 by Collin Anderson, 4 years ago

I can see the case for content negotiation.

My two sense: In browsers, there's a standard .json() method for http responses [0], and the Python requests library also has .json() method, so a simple .json() method is becoming more of the norm for a lot of simple use cases.

I don't think I'd be wrong if I said most apis only need to speak json. Content negotiation, while needed for some use cases, is probably overkill for many people's. Some people aren't going to want their endpoint to accept xml and yaml.

[0] https://developer.mozilla.org/en-US/docs/Web/API/Body/json

Version 0, edited 4 years ago by Collin Anderson (next)
Note: See TracTickets for help on using tickets.
Back to Top