Opened 9 months ago

Closed 9 months ago

Last modified 9 months 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


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

Change History (5)

comment:2 Changed 9 months ago by Mariusz Felisiak

Resolution: duplicate
Status: newclosed

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

comment:3 Changed 9 months ago by Carlton Gibson

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 Changed 9 months ago by Adam Johnson

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 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 Changed 9 months ago by Collin Anderson

I can see the case for content negotiation.

My two cents: 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.


Last edited 9 months ago by Collin Anderson (previous) (diff)
Note: See TracTickets for help on using tickets.
Back to Top