Skip to content

move ninja upload file out of import#432

Open
BryonLewis wants to merge 2 commits intomainfrom
ninja-uploadfile-fix
Open

move ninja upload file out of import#432
BryonLewis wants to merge 2 commits intomainfrom
ninja-uploadfile-fix

Conversation

@BryonLewis
Copy link
Collaborator

Uploading WAV files to the interface failed.
This was caused by the Django ninja accessing the type of the parameter, which was import UploadedFile from ninja.files.

Django-Ninja seems to access the type definition during runtime when used as a parameter for an endpoint:

https://github.com/vitalik/django-ninja/blob/56e868754e4ede8a47beb1833c8f67d4134339ea/ninja/signature/details.py#L221

https://github.com/vitalik/django-ninja/blob/56e868754e4ede8a47beb1833c8f67d4134339ea/ninja/signature/details.py#L57-L86

Here you can see that if you don't include the type annotation for HTTPRequest and your first parameter isn't named 'request', you can run into the same error.

@BryonLewis BryonLewis force-pushed the ninja-uploadfile-fix branch from 4adf588 to 209ec18 Compare March 12, 2026 18:00
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.

1 participant