Skip to content

Commit

Permalink
Add a missing piece to make a foreign key required
Browse files Browse the repository at this point in the history
  • Loading branch information
jalvaradosegura committed Oct 21, 2022
1 parent 75ce455 commit b3386f3
Showing 1 changed file with 1 addition and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,7 @@ This means that this attribute could be `None`, or it could be a full `Team` obj

This is because the related **`team_id` could also be `None`** (or `NULL` in the database).

If it was required for a `Hero` instance to belong to a `Team`, then the `team_id` would be `int` instead of `Optional[int]`.

And the `team` attribute would be a `Team` instead of `Optional[Team]`.
If it was required for a `Hero` instance to belong to a `Team`, then the `team_id` would be `int` instead of `Optional[int]`, its `Field` would be `Field(foreign_key="team.id")` instead of `Field(default=None, foreign_key="team.id")` and the `team` attribute would be a `Team` instead of `Optional[Team]`.

## Relationship Attributes With Lists

Expand Down

0 comments on commit b3386f3

Please sign in to comment.