Opened 27 hours ago

Last modified 66 minutes ago

#36245 closed New feature

Implement Configurable Content Type Parsing `request.data` to Modernize the HTTPRequest — at Version 3

Reported by: Adya Owned by: Adya
Component: HTTP handling Version: dev
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.

Change History (3)

comment:1 by Adya, 27 hours ago

Description: modified (diff)

comment:2 by Adya, 27 hours ago

Description: modified (diff)

comment:3 by Adya, 27 hours ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top