Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

document how to use an optional file input #1326

Merged
merged 1 commit into from
Oct 25, 2024

Conversation

toudi
Copy link
Contributor

@toudi toudi commented Oct 25, 2024

It took me a couple of google searches before I understood how to make the optional file input so I thought I'd help other people by extending the docs :)

@vitalik vitalik merged commit e070fab into vitalik:master Oct 25, 2024
@vitalik
Copy link
Owner

vitalik commented Oct 25, 2024

thank you

what was you intuitive feeling on how to make it optional ?

@toudi
Copy link
Contributor Author

toudi commented Oct 25, 2024

I tried couple of things. First thing I tried was to do file: UploadedFile = None, then UploadedFile | None = File(...), (but this one I think exploded on generating schema) then I tried UploadedFile = File(required=False) but then realized that required was not one of the parameters. I think it was due to my lack of experience. I then found the solution by pure accident by browsing trough issues of django-ninja and so I thought that I'd save some other developers some head-scratching time :)

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.

2 participants