Skip to content

Commit 608d7d5

Browse files
Update multiple-models.md
1 parent c13e657 commit 608d7d5

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

docs/tutorial/fastapi/multiple-models.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ The simplest way to solve it could be to create **multiple models**, each one wi
115115

116116
{* ./docs_src/tutorial/fastapi/multiple_models/tutorial001_py310.py *}
117117

118-
///
118+
////
119119

120120
Here's the important detail, and probably the most important feature of **SQLModel**: only `Hero` is declared with `table = True`.
121121

@@ -169,19 +169,19 @@ We can now create a new `Hero` instance (the one for the database) and put it in
169169

170170
{* ./docs_src/tutorial/fastapi/multiple_models/tutorial001_py310.py ln[47] hl[3] *}
171171

172-
///
172+
////
173173

174174
Then we just `add` it to the **session**, `commit`, and `refresh` it, and finally, we return the same `db_hero` variable that has the just refreshed `Hero` instance.
175175

176176
Because it is just refreshed, it has the `id` field set with a new ID taken from the database.
177177

178178
And now that we return it, FastAPI will validate the data with the `response_model`, which is a `HeroPublic`:
179179

180-
///
180+
////
181181

182182
{* ./docs_src/tutorial/fastapi/multiple_models/tutorial001_py310.py ln[44] hl[3] *}
183183

184-
///
184+
////
185185

186186
This will validate that all the data that we promised is there and will remove any data we didn't declare.
187187

@@ -232,7 +232,7 @@ We can see from above that they all share some **base** fields:
232232
* `age`, optional
233233

234234
So let's create a **base** model `HeroBase` that the others can inherit from:
235-
///
235+
////
236236

237237
{* ./docs_src/tutorial/fastapi/multiple_models/tutorial002_py310.py ln[5:8] hl[3:6] *}
238238

@@ -242,7 +242,7 @@ So let's create a **base** model `HeroBase` that the others can inherit from:
242242

243243
{* ./docs_src/tutorial/fastapi/multiple_models/tutorial002_py310.py *}
244244

245-
///
245+
////
246246

247247
As you can see, this is *not* a **table model**, it doesn't have the `table = True` config.
248248

@@ -260,7 +260,7 @@ Let's start with the only **table model**, the `Hero`:
260260

261261
{* ./docs_src/tutorial/fastapi/multiple_models/tutorial002_py310.py *}
262262

263-
///
263+
////
264264

265265
Notice that `Hero` now doesn't inherit from `SQLModel`, but from `HeroBase`.
266266

@@ -305,7 +305,7 @@ This is a fun one:
305305

306306
{* ./docs_src/tutorial/fastapi/multiple_models/tutorial002_py310.py *}
307307

308-
///
308+
////
309309

310310
What's happening here?
311311

@@ -334,7 +334,7 @@ This one just declares that the `id` field is required when reading a hero from
334334

335335
{* ./docs_src/tutorial/fastapi/multiple_models/tutorial002_py310.py *}
336336

337-
///
337+
////
338338

339339
## Review the Updated Docs UI
340340

0 commit comments

Comments
 (0)