]> git.ipfire.org Git - thirdparty/fastapi/sqlmodel.git/commitdiff
📝 Update instructions about how to make a foreign key required in `docs/tutorial...
authorJorge Alvarado <alvaradosegurajorge@gmail.com>
Sun, 22 Oct 2023 12:03:51 +0000 (09:03 -0300)
committerGitHub <noreply@github.com>
Sun, 22 Oct 2023 12:03:51 +0000 (16:03 +0400)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
docs/tutorial/relationship-attributes/define-relationships-attributes.md

index 0531ec53e57863d2fbc2a481893dc4659d53d329..b6e77d9b45962d067c5dba7ce4806fb0aa095219 100644 (file)
@@ -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