Opened 15 hours ago

Closed 14 hours ago

#36245 closed New feature (duplicate)

Implement Configurable Content Type Parsing `request.data` to Modernize the HTTPRequest

Reported by: Adya Owned by: Adya
Component: HTTP handling Version: 5.1
Severity: Normal Keywords: parsing, http
Cc: Adya Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Adya)

Adding a new feature to modernize the HTTPRequest object, adding a content-type aware request.data property. This will parse request.body according to the content type.

In the initial phase, I will add request.data and add support for JSON body handling, but the next phase is to make that fully pluggable with custom parsers.

This Feature Idea is described in the Django GSoC 2025 Wiki page https://code.djangoproject.com/wiki/SummerOfCode2025#ConfigurableContentTypeParsing

This kind of feature is already implemented in *Django REST Framework* I have read the source code, DRF, Django docs, MDN reference on HTTP, and implemented it in my local Django project.
A [PlanEnglish.io Python blog](https://python.plainenglish.io/django-rest-api-tutorial-mastering-parsers-with-practical-examples-d24872c47849) described it so well.

Outcome after completing this feature
Developers will have a more streamlined and efficient way to access request data
For instance, with request.body, a developer working with JSON data would need to write

import json
data = json.loads(request.body)
user_name = data.get('name')

With the proposed request.data, this simplifies to something like:

user_name = request.data.get('name')

I am creating the test cases and patches for this implementation, then will PR it

Implementation Plan:

  • Write test cases
  • Add the request.data property to HTTPRequest.
  • Implement initial JSON parsing logic.

_I AM ASKING FOR TRIAGE_

Change History (5)

comment:1 by Adya, 15 hours ago

Description: modified (diff)

comment:2 by Adya, 15 hours ago

Description: modified (diff)

comment:3 by Adya, 15 hours ago

Description: modified (diff)

comment:4 by Adya, 15 hours ago

Description: modified (diff)

comment:5 by Sarah Boyce, 14 hours ago

Resolution: duplicate
Status: assignedclosed

Thank you! I think this is a duplicate of #21442

Note: See TracTickets for help on using tickets.
Back to Top