r/FastAPI • u/Lucky-Sense-2650 • 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
View all comments
Show parent comment
2
u/Lucky-Sense-2650 Jun 22 '26
Yes, and which method is best/ optimized .