Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@vobinics
Copy link

@vobinics vobinics commented Oct 6, 2020

Fixed error 422 when creating Pydantic model from FormData. Example temporal workaround on StackOverflow

@codecov
Copy link

codecov bot commented Oct 6, 2020

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (e77ea63) 100.00% compared to head (e6ec56d) 100.00%.
Report is 2321 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #2139   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          239       240    +1     
  Lines         7079      7104   +25     
=========================================
+ Hits          7079      7104   +25     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 6, 2020

📝 Docs preview for commit e6ec56d at: https://5f7cddf0dd4b3c014cae6e71--fastapi.netlify.app

@Fkawala
Copy link

Fkawala commented Jul 12, 2021

Hey, I'd be interest to have this merged, is there anything blocking this to be merged ? Thank you !

@iudeen
Copy link
Contributor

iudeen commented Nov 7, 2022

I tried


from fastapi import FastAPI, Form, Depends, UploadFile
from pydantic import BaseModel

app = FastAPI()


class SimpleModel(BaseModel):
    no: int = Form(...)
    nm: str = Form(...)
    f: UploadFile = Form(...)


@app.post("/form")
async def form_post(form_data: SimpleModel = Depends()):
    fp = await form_data.f.read()
    print(fp)

It works with current (0.86) version. Is this PR still needed?

@tiangolo tiangolo added the feature New feature or request label Oct 2, 2023
@tiangolo tiangolo added p4 and removed investigate labels Jan 15, 2024
@tiangolo
Copy link
Member

tiangolo commented Sep 8, 2024

Thanks! ☕

This was covered in #12129, it is available in FastAPI 0.113.0 🎉

The new docs: https://fastapi.tiangolo.com/tutorial/request-form-models/

Given that, I'll close this one, but thanks for the effort! 🍰

@tiangolo tiangolo closed this Sep 8, 2024
@codecov-commenter
Copy link

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Files with missing lines Coverage Δ
fastapi/dependencies/utils.py 100.00% <100.00%> (ø)
tests/test_pydantic_model_in_form.py 100.00% <100.00%> (ø)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request p4

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants