[Django] #36841: Add multipart_parser_class attribute to HttpRequest for pluggable multipart parsing

9 views
Skip to first unread message

Django

unread,
Jan 5, 2026, 11:15:21 AMJan 5
to django-...@googlegroups.com
#36841: Add multipart_parser_class attribute to HttpRequest for pluggable multipart
parsing
-------------------------------------+-------------------------------------
Reporter: Farhan | Owner: (none)
Ali |
Type: New | Status: assigned
feature |
Component: HTTP | Version: dev
handling |
Severity: Normal | Keywords: mutipart-parsing
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
== Problem

Django's `parse_file_upload()` hardcodes `MultiPartParser`, making it hard
to swap in faster implementations.

== Proposed Solution

As discussed with the steering council and Carlton Gibson on the forum:

1. Add `multipart_parser_class` class attribute to `HttpRequest`
(defaulting to `MultiPartParser`)

2. Modify `parse_file_upload()` to use `self.multipart_parser_class`
instead of direct import

3. Ensure uniform parser interface: `__init__(META, input_data,
upload_handlers, encoding)`
with `parse()` returning `(POST, FILES)`

== Usage

Users can subclass `HttpRequest` and override `multipart_parser_class` to
use
faster parsers.

== Benefits

- Immediate performance improvements for those who need them
- Stepping stone toward DEP 17 https://github.com/django/deps/pull/88
(pluggable content type parsers)
- Minimal change
- Follows proven pattern from Django REST Framework's `parser_classes`

== Forum Discussion
https://github.com/django/new-features/issues/105
--
Ticket URL: <https://code.djangoproject.com/ticket/36841>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jan 5, 2026, 11:15:49 AMJan 5
to django-...@googlegroups.com
#36841: Add multipart_parser_class attribute to HttpRequest for pluggable multipart
parsing
----------------------------------+--------------------------------------
Reporter: Farhan Ali | Owner: Farhan Ali
Type: New feature | Status: assigned
Component: HTTP handling | Version: dev
Severity: Normal | Resolution:
Keywords: mutipart-parsing | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+--------------------------------------
Changes (by Farhan Ali):

* owner: (none) => Farhan Ali

--
Ticket URL: <https://code.djangoproject.com/ticket/36841#comment:1>

Django

unread,
Jan 5, 2026, 12:54:59 PMJan 5
to django-...@googlegroups.com
#36841: Add multipart_parser_class attribute to HttpRequest for pluggable multipart
parsing
----------------------------------+--------------------------------------
Reporter: Farhan Ali | Owner: Farhan Ali
Type: New feature | Status: assigned
Component: HTTP handling | Version: dev
Severity: Normal | Resolution:
Keywords: mutipart-parsing | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+--------------------------------------
Changes (by Natalia Bidart):

* stage: Unreviewed => Accepted

Comment:

Thanks for opening the ticket and for following the prior discussion!

The DRF comparison is useful as prior art, but this does not add view-
level `parser_classes`, keeping the scope intentionally small.
Configurability via a custom `HttpRequest` subclass is sufficient at this
stage and keeps the change minimal.

Proceeding with a PR along these lines sounds good, looking forward to
that!
--
Ticket URL: <https://code.djangoproject.com/ticket/36841#comment:2>

Django

unread,
Jan 5, 2026, 2:36:14 PMJan 5
to django-...@googlegroups.com
#36841: Add multipart_parser_class attribute to HttpRequest for pluggable multipart
parsing
----------------------------------+--------------------------------------
Reporter: Farhan Ali | Owner: Farhan Ali
Type: New feature | Status: assigned
Component: HTTP handling | Version: dev
Severity: Normal | Resolution:
Keywords: mutipart-parsing | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+--------------------------------------
Changes (by Farhan Ali):

* has_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/36841#comment:3>

Django

unread,
Jan 5, 2026, 2:44:03 PMJan 5
to django-...@googlegroups.com
#36841: Add multipart_parser_class attribute to HttpRequest for pluggable multipart
parsing
----------------------------------+--------------------------------------
Reporter: Farhan Ali | Owner: Farhan Ali
Type: New feature | Status: assigned
Component: HTTP handling | Version: dev
Severity: Normal | Resolution:
Keywords: mutipart-parsing | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+--------------------------------------
Comment (by Farhan Ali):

Opened a PR https://github.com/django/django/pull/20498. But it will need
a guide in the docs, I think how to use this feature properly.
--
Ticket URL: <https://code.djangoproject.com/ticket/36841#comment:4>

Django

unread,
Jan 5, 2026, 5:51:12 PMJan 5
to django-...@googlegroups.com
#36841: Add multipart_parser_class attribute to HttpRequest for pluggable multipart
parsing
----------------------------------+--------------------------------------
Reporter: Farhan Ali | Owner: Farhan Ali
Type: New feature | Status: assigned
Component: HTTP handling | Version: dev
Severity: Normal | Resolution:
Keywords: mutipart-parsing | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+--------------------------------------
Changes (by Jacob Walls):

* needs_docs: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/36841#comment:5>

Django

unread,
Jan 6, 2026, 3:21:26 PMJan 6
to django-...@googlegroups.com
#36841: Add multipart_parser_class attribute to HttpRequest for pluggable multipart
parsing
----------------------------------+--------------------------------------
Reporter: Farhan Ali | Owner: Farhan Ali
Type: New feature | Status: assigned
Component: HTTP handling | Version: dev
Severity: Normal | Resolution:
Keywords: mutipart-parsing | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+--------------------------------------
Changes (by Farhan Ali):

* needs_docs: 1 => 0

--
Ticket URL: <https://code.djangoproject.com/ticket/36841#comment:6>
Reply all
Reply to author
Forward
0 new messages