You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
How does one define a many to one relationship in my models so that when I query for all pets, the Pet Type Model is returned as well?
Have two tables
pets
id(int) - Primary Key
name(varchar)
pet_type_id(int) - Foreign Key
pet_type
id(int) - Primary Key
name (str)
I have the foreign set up as
here are my models:
This doesn't seem to load the PetModel as expected. I am expecting this
PetModel(
{
"id": 1,
"name": "Fido",
"pet_type": PetTypeModel(
{
"id": 1,
"name": "Dog",
}
),
}
)
But pet_type is always []
Can anyone help me with this? I'm willing to pay for the help because once I figure this out, it'll unlock everything else for me mentally.
Beta Was this translation helpful? Give feedback.
All reactions