Skip to content
Discussion options

You must be logged in to vote

You can't simply add a user_email field to that schema and expect it to be populated. Rather,
you need to also create a User schema. Otherwise Pydantic won't now how to connect the two models.

class User(BaseModel):
    class Config:
        orm_mode = True
    
    id: str
    email: str
    hashed_password: str

class ShiftDetailBase(BaseModel)
    # add field for the owner (reference User model)
    # I believe you can remove the owner_id field
    owner: User

The response would then look like:

[
  {
    "shift_id": "5240b998-7919-11ea-8f22-001a7dda7111",
    "owner_id": 56277c6c-7918-11ea-850b-001a7dda7111,
    "shift_date": "2020-04-08",
    "id": "87845423-795f-11ea-a51f-001a7dda711…

Replies: 17 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by YuriiMotov
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies

This comment was marked as off-topic.

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
9 participants
Converted from issue

This discussion was converted from issue #140 on September 03, 2025 06:15.