Skip to content

Conversation

@vitalik
Copy link
Owner

@vitalik vitalik commented Mar 14, 2025

This PR addresses a longstanding Django issue where request.FILES is only populated when the request method is POST, ignoring file uploads for other HTTP methods.

While this behavior may have aligned with how browsers handled file uploads in the past, modern browsers and HTTP clients allow file uploads with any method.

This PR introduces a check for non-POST methods that accept file uploads. If such a request is detected, Django-Ninja will raise an error with a suggestion to enable a specific middleware that corrects this behavior by ensuring request.FILES is properly populated.

can be disabled with settings.NINJA_FIX_REQUEST_FILES_METHODS = []

CC @baseplate-admin (https://github.com/baseplate-admin/ninja_put_patch_file_upload_middleware)

@baseplate-admin
Copy link
Contributor

Thank you for including this.

All good from my side :D

@vitalik vitalik merged commit 37fbd62 into master Mar 15, 2025
74 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants