#36245: Implement Configurable Content Type Parsing `request.data` to Modernize the HTTPRequest -------------------------------+-------------------------------------- Reporter: Adya | Owner: Adya Type: New feature | Status: assigned Component: HTTP handling | Version: 5.1 Severity: Normal | Resolution: Keywords: parsing, http | Triage Stage: Unreviewed Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------+-------------------------------------- Description changed by Adya:
Old description: > 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 > > ```python > 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 PR > it > **Implementation Plan:** > - Write test cases > - Add the request.data property to HTTPRequest. > - Implement initial JSON parsing logic. New description: 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 ```python import json data = json.loads(request.body) user_name = data.get('name') ``` With the proposed `request.data`, this simplifies to something like: ```python user_name = request.data.get('name') ``` I am creating the test cases and patches for this implementation then PR it **Implementation Plan:** - Write test cases - Add the request.data property to HTTPRequest. - Implement initial JSON parsing logic. -- -- Ticket URL: <https://code.djangoproject.com/ticket/36245#comment:1> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/django-updates/0107019585826753-7873dd52-23e3-4c35-b71d-75fcd1cc2ae2-000000%40eu-central-1.amazonses.com.