]> git.ipfire.org Git - thirdparty/fastapi/fastapi.git/commitdiff
📝 Update includes for `docs/en/docs/tutorial/body-updates.md` (#12712)
authordavioc <14282722+davioc@users.noreply.github.com>
Sun, 10 Nov 2024 17:26:01 +0000 (09:26 -0800)
committerGitHub <noreply@github.com>
Sun, 10 Nov 2024 17:26:01 +0000 (17:26 +0000)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
docs/en/docs/tutorial/body-updates.md

index 3ac2e391497fbded09267630851cbed9836766b8..df5b960db6f3344c72385a7dadea32aceecd0d01 100644 (file)
@@ -6,29 +6,7 @@ To update an item you can use the <a href="https://developer.mozilla.org/en-US/d
 
 You can use the `jsonable_encoder` to convert the input data to data that can be stored as JSON (e.g. with a NoSQL database). For example, converting `datetime` to `str`.
 
-//// tab | Python 3.10+
-
-```Python hl_lines="28-33"
-{!> ../../docs_src/body_updates/tutorial001_py310.py!}
-```
-
-////
-
-//// tab | Python 3.9+
-
-```Python hl_lines="30-35"
-{!> ../../docs_src/body_updates/tutorial001_py39.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="30-35"
-{!> ../../docs_src/body_updates/tutorial001.py!}
-```
-
-////
+{* ../../docs_src/body_updates/tutorial001_py310.py hl[28:33] *}
 
 `PUT` is used to receive data that should replace the existing data.
 
@@ -84,29 +62,7 @@ That would generate a `dict` with only the data that was set when creating the `
 
 Then you can use this to generate a `dict` with only the data that was set (sent in the request), omitting default values:
 
-//// tab | Python 3.10+
-
-```Python hl_lines="32"
-{!> ../../docs_src/body_updates/tutorial002_py310.py!}
-```
-
-////
-
-//// tab | Python 3.9+
-
-```Python hl_lines="34"
-{!> ../../docs_src/body_updates/tutorial002_py39.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="34"
-{!> ../../docs_src/body_updates/tutorial002.py!}
-```
-
-////
+{* ../../docs_src/body_updates/tutorial002_py310.py hl[32] *}
 
 ### Using Pydantic's `update` parameter
 
@@ -122,29 +78,7 @@ The examples here use `.copy()` for compatibility with Pydantic v1, but you shou
 
 Like `stored_item_model.model_copy(update=update_data)`:
 
-//// tab | Python 3.10+
-
-```Python hl_lines="33"
-{!> ../../docs_src/body_updates/tutorial002_py310.py!}
-```
-
-////
-
-//// tab | Python 3.9+
-
-```Python hl_lines="35"
-{!> ../../docs_src/body_updates/tutorial002_py39.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="35"
-{!> ../../docs_src/body_updates/tutorial002.py!}
-```
-
-////
+{* ../../docs_src/body_updates/tutorial002_py310.py hl[33] *}
 
 ### Partial updates recap
 
@@ -161,29 +95,7 @@ In summary, to apply partial updates you would:
 * Save the data to your DB.
 * Return the updated model.
 
-//// tab | Python 3.10+
-
-```Python hl_lines="28-35"
-{!> ../../docs_src/body_updates/tutorial002_py310.py!}
-```
-
-////
-
-//// tab | Python 3.9+
-
-```Python hl_lines="30-37"
-{!> ../../docs_src/body_updates/tutorial002_py39.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="30-37"
-{!> ../../docs_src/body_updates/tutorial002.py!}
-```
-
-////
+{* ../../docs_src/body_updates/tutorial002_py310.py hl[28:35] *}
 
 /// tip