From 5442f853e53a14768612284f0ebbd15837bf7cfd Mon Sep 17 00:00:00 2001 From: stabldev <114811070+stabldev@users.noreply.github.com> Date: Tue, 30 Sep 2025 11:04:17 +0530 Subject: [PATCH] docs: update optional file type annotations --- docs/docs/guides/input/file-params.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/docs/docs/guides/input/file-params.md b/docs/docs/guides/input/file-params.md index 39aa91861..8e301e970 100644 --- a/docs/docs/guides/input/file-params.md +++ b/docs/docs/guides/input/file-params.md @@ -77,7 +77,7 @@ def create_user(request, details: UserDetails, file: File[UploadedFile]): ``` this will expect from the client side to send data as `multipart/form-data with 2 fields: - + - details: JSON as string - file: file @@ -96,7 +96,7 @@ If you would like the file input to be optional, all that you have to do is to p ```python @api.post('/users') -def create_user(request, details: Form[UserDetails], avatar: File[UploadedFile] = None): +def create_user(request, details: Form[UserDetails], avatar: Optional[File[UploadedFile]] = None): user = add_user_to_database(details) if avatar is not None: set_user_avatar(user) @@ -141,5 +141,3 @@ When Django Ninja detects a PUT or PATCH etc methods with multipart/form-data a Note: This middleware does not interfere with normal POST behavior or any other methods. - -