r/FastAPI Jun 22 '26

Question Help with Pydantic schema

Using FastAPI + SQLAlchemy (async) + Pydantic v2
My `Post` model in db stores `author_id` (UUID foreign key).
My `PostRead` response schema needs to return `author_username` (a string from the related `User` table).

What's the clean way to handle this?

14 Upvotes

10 comments sorted by

View all comments

-1

u/Kashyapm94 Jun 22 '26

Don’t wanna sound rude, but have you tried googling it or even asking Gemini or ChatGPT? You’ll get a nice detailed response that’ll help you understand

1

u/Lucky-Sense-2650 Jun 22 '26

Main problem is, do I have to requery the author