Hi. Happy New Year.
I need to ask for a Steering Council (@steering_council) approval (vote under rules of DEP 10) for a proposal to modernise the API of the HttpRequest
object, whilst adding content type aware parsing, such that (in particular) JSON request bodies can be handled automatically.
The body of the proposal is that new attributes are added to the request, which are roughly equivalent to the existing GET
&co, but which have more modern names:
query_params
(forGET
)data
(forPOST
, but see note)files
(forFILES
)meta
(forMETA
)
The new data
attribute is not 100% equivalent to POST
since it will parse JSON (and other data types as parsers for those are configured) where POST
would return a string.
(The behaviour for multipart requests will also be slightly different as per the django-developers thread linked below.)
The existing GET
, POST
, META
, and FILES
attributes will be maintained for backwards compatibility, and (to emphasise again) the behaviour (specifically of POST
) will remain unchanged.
This is similar to the way the headers
property was added, whilst maintaining the older dictionary style lookup.
Modernising the request, whilst attractive in itself, gives us the opportunity to resolve the long-standing content negotiation issue, which has been blocked several times for backwards compatibility concerns.
There are two open PRs relevant to this:
- Refs #21442 – Modernising Request Object Attribute Names. By SirAbhi13 · Pull Request #17624 · Django/Django
- Refs #21442 – Added Content Type Parsing by smithdc1 · Pull Request #17546 · Django/Django
The request is to be able to push these forwards, subject to the usual reviews and quality requirements. (They’re not yet finished.)
To recall the history here:
- We were about to merge the fix for ticket-32259, before @felixxm thought under review that it was too disruptive. He and I (as the current fellows at that time) discussed and agreed on this.
- @adamchainz asked for technical board review wherein it was agreed that allowing the suggestion of buying some functionality with the content negotiation work should be explored.
- I followed up with a thread to Advance the content negotiation proposal attempting to fulfil that promise, where it was agreed that we would proceed on this basis.
Mariusz has raised the same concerns again now, and we would like the Steering Council to decide the way forward.
Please vote on whether to approve advancing the two PRs. (Taking +1 to be for doing so, -1 to be against, to align with the DEP 10 voting procedure.)
If the decision is against, can I ask the Steering Council to provide guidance as to how we might or should then move forward with efforts to modernise the request.
Thanks!
Carlton