-
-
Notifications
You must be signed in to change notification settings - Fork 6k
Fix models to support pydantic orm_mode #43
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
Happy to second that ;) I think its fairly urgent to merge this PR ( @tiangolo ), since it does break the test suite perhaps running CI nightly is of interest, that'll help catching upstream changes |
Here is a 👍 from me too, for this lifesaving tip! This ought to be merged! |
I have ran into this issue as well. |
See GitHub PR fastapi#43 fastapi#43 See GitHub issue fastapi#72 fastapi#72 When viewing the user profile, name and email weren't showing up. Docker Compose logs showed a pydantic error: https://pydantic-docs.helpmanual.io/ ``` backend_1 | pydantic.error_wrappers.ValidationError: 1 validation error for User backend_1 | response -> 0 backend_1 | value is not a valid dict (type=type_error.dict) ``` Pydantic orm_mode is needed. This commit will update the database models to use pydantic orm_mode, with cleaner syntax than the fix suggested in issue fastapi#72 (by adding class Config directly to the base class).
Thanks @ac3d912 for debugging and implementing it! 🎉 🚀 Thanks everyone for the discussion here (and the patience 😅 ). @StephenBrown2 , yep, thanks. This was fixed as part of that PR. I'll close this PR now as the fix is already implemented (from a different PR). |
Null (None) values will cause ValidationErrors when used with postgres.
See: fastapi/fastapi#361 (comment)
I made these changes and it works like a charm. (The issue out-of-the-box being the None value for first superuser's Full Name)
FastAPI version: 0.33.0
Pydantic version: 0.30
Example validation error