django-fast-multipart
django-fast-multipart provides a Rust-backed implementation of Django's
multipart upload parser interface. It uses the
HttpRequest.multipart_parser_class extension point introduced in Django 6.1
and integrates with Django's existing upload-handler contract.
The project is currently beta. Its behavior is tested against Django's
MultiPartParser, but broader custom upload-handler compatibility still needs
production feedback.
Compatibility
The differential test suite sends identical request bodies through Django's
parser and RustMultiPartParser, then compares the resulting POST and
FILES values, exceptions, stream consumption, and upload-handler callbacks.
A deterministic property-based suite also generates multipart structures,
binary and boundary-like payloads, input chunk sizes, and Django upload limits.
The following behavior is covered:
- normal and repeated form fields;
- incremental request reads, including one-byte chunks;
- in-memory and temporary-file upload handlers;
StopFutureHandlers,SkipFile, and bothStopUploadmodes;- interrupted-upload signaling and temporary-file cleanup;
- field-memory, field-count, and file-count limits;
- Django's 1,024-byte aggregate part-header limit;
- truncated fields and interrupted files at end of input;
- raw boundary tokens embedded in part data;
- Django boundary values through 201 bytes;
- Django-compatible handling of malformed part-header lines;
- base64 transfer encoding for form fields and file uploads;
- preambles, epilogues, raw inter-boundary segments, and parts following a closing-boundary marker;
- Django's parser constructor and return-value contract.
Known limitations:
- custom upload-handler edge cases beyond those listed above are not yet fully covered.
Usage
django-fast-multipart requires Python 3.12 or later and Django 6.1.
Middleware
For application-wide use, add the included middleware:
MIDDLEWARE = [
"django_fast_multipart.middleware.FastMultipartMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
# Other middleware...
]
Place it before any middleware that accesses request.POST or request.FILES.
Django uses the parser class that is configured when either collection is
first read. The middleware supports both synchronous and asynchronous request
stacks.
Per-request selection
The parser can be selected in a view when no earlier middleware has accessed the request data:
from django_fast_multipart import RustMultiPartParser
def upload(request):
request.multipart_parser_class = RustMultiPartParser
uploaded_file = request.FILES["file"]
# Process the uploaded file.
Existing upload-handler configuration remains in effect. The parser uses Django's configured upload handlers and enforces its field-memory, field-count, and file-count settings.
Native core
The native parser is included in this repository and built as the private
django_fast_multipart._core extension. It is derived from
rust-multipart. See
THIRD_PARTY_NOTICES.md for the source revision and
licensing details.
Source distributions include the Rust sources and lockfile; installation does not fetch parser code from a Git repository.
Distribution support
Distribution CI builds and installs CPython stable-ABI wheels for manylinux x86-64 and ARM64, macOS on Intel and Apple Silicon, and Windows x86-64. The stable ABI supports the project's CPython 3.12-or-later compatibility range without producing a wheel for each Python minor release.
The source distribution remains available for other platforms, but installing it requires a Rust toolchain and a compatible native build environment.
Development
See the
RELEASING.md
guide for the release process.
The locked development environment uses the released Django 6.1 series:
uv sync
uv run pytest
uv run ruff check .
uv run ruff format --check .
cargo fmt --manifest-path rust/Cargo.toml --check
cargo clippy --manifest-path rust/Cargo.toml --locked --all-targets --all-features -- -D warnings
uv build
Native parser fuzzing
The native parser has a libFuzzer target that compares contiguous and
incremental parsing. It requires nightly Rust and cargo-fuzz:
ASAN_OPTIONS=detect_leaks=0 \
cargo +nightly fuzz run --fuzz-dir fuzz multipart_parser -- \
-dict=fuzz/dictionaries/multipart_parser.dict
Parser benchmarks
Timing and peak-memory benchmarks compare Django's parser with the native
implementation. See benchmarks/README.md for the
cases, commands, exploratory results, host limitations, and profiling
observations. The reference results are parser-level measurements, not
end-to-end application performance claims. The benchmark workflow is manual
and does not enforce performance thresholds.
Testing against Django main
CI runs an advisory compatibility suite against Django's main branch. To run the same suite with a local Django checkout:
PYTHONPATH=/path/to/django uv run --no-sync pytest
Metadata
Release files for django-fast-multipart 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| django_fast_multipart-0.1.0.tar.gz | 16.0 kB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| django_fast_multipart-0.1.0-cp312-abi3-win_amd64.whl | CPython 3.12 | abi3 | Windows x86-64 | Details |
| django_fast_multipart-0.1.0-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.12 | abi3 | Linux glibc 2.17+ x86-64 | Details |
| django_fast_multipart-0.1.0-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl | CPython 3.12 | abi3 | Linux glibc 2.17+ ARM64 | Details |
| django_fast_multipart-0.1.0-cp312-abi3-macosx_11_0_arm64.whl | CPython 3.12 | abi3 | macOS 11.0+ ARM64 | Details |
| django_fast_multipart-0.1.0-cp312-abi3-macosx_10_12_x86_64.whl | CPython 3.12 | abi3 | macOS 10.12+ x86-64 | Details |
Total release size: 1.2 MB
Release files / django_fast_multipart-0.1.0.tar.gz
| Download URL | django_fast_multipart-0.1.0.tar.gz |
|---|---|
| Size | 16.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
929374362c5ae6afe435165b419858e064b20e6dcc9eb343874000fa632f4e4e
|
|
BLAKE2b-256 checksum How to use checksums |
2ea2699a36cdd935c5d261e02ff515eba63ffd0ae63db17fa50af0403b5a7fb5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 27, 2026.
Transparency logRelease files / django_fast_multipart-0.1.0-cp312-abi3-win_amd64.whl
| Download URL | django_fast_multipart-0.1.0-cp312-abi3-win_amd64.whl |
|---|---|
| Size | 160.8 kB |
| Tags | CPython 3.12 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
512f34f94e5199bd119d085ee8a26b607f9a7c25ae20e8893f56d747a2e17da0
|
|
BLAKE2b-256 checksum How to use checksums |
67b0203f27d6b1ef480b7902858d947720e7cbc3b2d6153ef176881421a207a8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 27, 2026.
Transparency logRelease files / django_fast_multipart-0.1.0-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | django_fast_multipart-0.1.0-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 276.8 kB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
74022f85fed39fadbdb97bbd8497ae4e3368a3f4c327f9a1ef6ec48c57df7d52
|
|
BLAKE2b-256 checksum How to use checksums |
96adfef6b8cbc9c481e9be0837d98afbf07e9737e06402a078716881823ebb6c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 27, 2026.
Transparency logRelease files / django_fast_multipart-0.1.0-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | django_fast_multipart-0.1.0-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 269.7 kB |
| Tags | CPython 3.12 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
4bf7f1d8cf45b753ae9ab1b70af1230a4a75eb010f3aa5a085e4b2cdecdddc98
|
|
BLAKE2b-256 checksum How to use checksums |
226f456f3fe5867f2bba2a5c23233e104bdf60e3a3fe4d8935b3dfefd14ca3b0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 27, 2026.
Transparency logRelease files / django_fast_multipart-0.1.0-cp312-abi3-macosx_11_0_arm64.whl
| Download URL | django_fast_multipart-0.1.0-cp312-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 247.6 kB |
| Tags | CPython 3.12 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
afa022489169ad81bdecb53f8fec4bf24418452488ff1192f132495ec51ee03c
|
|
BLAKE2b-256 checksum How to use checksums |
982e7b2df139e161c2f7c146e6fe21f44df0f37c0072f76e24c37a8dcbeec66d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 27, 2026.
Transparency logRelease files / django_fast_multipart-0.1.0-cp312-abi3-macosx_10_12_x86_64.whl
| Download URL | django_fast_multipart-0.1.0-cp312-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 261.2 kB |
| Tags | CPython 3.12 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
356377c828a4b89a232b338ab2c1147b0565d8e76aeb79099ae7db243a0bdfd4
|
|
BLAKE2b-256 checksum How to use checksums |
d79590a8231d8033fbe7d36ada3a603d17124d790972ef1b59f0f44235f38631
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 27, 2026.
Transparency log