mirror of https://github.com/tiangolo/fastapi.git
101 lines
3.2 KiB
Markdown
101 lines
3.2 KiB
Markdown
# 💪 - ℹ
|
||
|
||
## ℹ ❎ ⏮️ `PUT`
|
||
|
||
ℹ 🏬 👆 💪 ⚙️ <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PUT" class="external-link" target="_blank">🇺🇸🔍 `PUT`</a> 🛠️.
|
||
|
||
👆 💪 ⚙️ `jsonable_encoder` 🗜 🔢 💽 📊 👈 💪 🏪 🎻 (✅ ⏮️ ☁ 💽). 🖼, 🏭 `datetime` `str`.
|
||
|
||
{* ../../docs_src/body_updates/tutorial001.py hl[30:35] *}
|
||
|
||
`PUT` ⚙️ 📨 💽 👈 🔜 ❎ ♻ 💽.
|
||
|
||
### ⚠ 🔃 ❎
|
||
|
||
👈 ⛓ 👈 🚥 👆 💚 ℹ 🏬 `bar` ⚙️ `PUT` ⏮️ 💪 ⚗:
|
||
|
||
```Python
|
||
{
|
||
"name": "Barz",
|
||
"price": 3,
|
||
"description": None,
|
||
}
|
||
```
|
||
|
||
↩️ ⚫️ 🚫 🔌 ⏪ 🏪 🔢 `"tax": 20.2`, 🔢 🏷 🔜 ✊ 🔢 💲 `"tax": 10.5`.
|
||
|
||
& 📊 🔜 🖊 ⏮️ 👈 "🆕" `tax` `10.5`.
|
||
|
||
## 🍕 ℹ ⏮️ `PATCH`
|
||
|
||
👆 💪 ⚙️ <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PATCH" class="external-link" target="_blank">🇺🇸🔍 `PATCH`</a> 🛠️ *🍕* ℹ 💽.
|
||
|
||
👉 ⛓ 👈 👆 💪 📨 🕴 💽 👈 👆 💚 ℹ, 🍂 🎂 🐣.
|
||
|
||
/// note
|
||
|
||
`PATCH` 🌘 🛎 ⚙️ & 💭 🌘 `PUT`.
|
||
|
||
& 📚 🏉 ⚙️ 🕴 `PUT`, 🍕 ℹ.
|
||
|
||
👆 **🆓** ⚙️ 👫 👐 👆 💚, **FastAPI** 🚫 🚫 🙆 🚫.
|
||
|
||
✋️ 👉 🦮 🎦 👆, 🌖 ⚖️ 🌘, ❔ 👫 🎯 ⚙️.
|
||
|
||
///
|
||
|
||
### ⚙️ Pydantic `exclude_unset` 🔢
|
||
|
||
🚥 👆 💚 📨 🍕 ℹ, ⚫️ 📶 ⚠ ⚙️ 🔢 `exclude_unset` Pydantic 🏷 `.dict()`.
|
||
|
||
💖 `item.dict(exclude_unset=True)`.
|
||
|
||
👈 🔜 🏗 `dict` ⏮️ 🕴 💽 👈 ⚒ 🕐❔ 🏗 `item` 🏷, 🚫 🔢 💲.
|
||
|
||
⤴️ 👆 💪 ⚙️ 👉 🏗 `dict` ⏮️ 🕴 💽 👈 ⚒ (📨 📨), 🚫 🔢 💲:
|
||
|
||
{* ../../docs_src/body_updates/tutorial002.py hl[34] *}
|
||
|
||
### ⚙️ Pydantic `update` 🔢
|
||
|
||
🔜, 👆 💪 ✍ 📁 ♻ 🏷 ⚙️ `.copy()`, & 🚶♀️ `update` 🔢 ⏮️ `dict` ⚗ 💽 ℹ.
|
||
|
||
💖 `stored_item_model.copy(update=update_data)`:
|
||
|
||
{* ../../docs_src/body_updates/tutorial002.py hl[35] *}
|
||
|
||
### 🍕 ℹ 🌃
|
||
|
||
📄, ✔ 🍕 ℹ 👆 🔜:
|
||
|
||
* (⚗) ⚙️ `PATCH` ↩️ `PUT`.
|
||
* 🗃 🏪 💽.
|
||
* 🚮 👈 💽 Pydantic 🏷.
|
||
* 🏗 `dict` 🍵 🔢 💲 ⚪️➡️ 🔢 🏷 (⚙️ `exclude_unset`).
|
||
* 👉 🌌 👆 💪 ℹ 🕴 💲 🤙 ⚒ 👩💻, ↩️ 🔐 💲 ⏪ 🏪 ⏮️ 🔢 💲 👆 🏷.
|
||
* ✍ 📁 🏪 🏷, 🛠️ ⚫️ 🔢 ⏮️ 📨 🍕 ℹ (⚙️ `update` 🔢).
|
||
* 🗜 📁 🏷 🕳 👈 💪 🏪 👆 💽 (🖼, ⚙️ `jsonable_encoder`).
|
||
* 👉 ⭐ ⚙️ 🏷 `.dict()` 👩🔬 🔄, ✋️ ⚫️ ⚒ 💭 (& 🗜) 💲 💽 🆎 👈 💪 🗜 🎻, 🖼, `datetime` `str`.
|
||
* 🖊 💽 👆 💽.
|
||
* 📨 ℹ 🏷.
|
||
|
||
{* ../../docs_src/body_updates/tutorial002.py hl[30:37] *}
|
||
|
||
/// tip
|
||
|
||
👆 💪 🤙 ⚙️ 👉 🎏 ⚒ ⏮️ 🇺🇸🔍 `PUT` 🛠️.
|
||
|
||
✋️ 🖼 📥 ⚙️ `PATCH` ↩️ ⚫️ ✍ 👫 ⚙️ 💼.
|
||
|
||
///
|
||
|
||
/// note
|
||
|
||
👀 👈 🔢 🏷 ✔.
|
||
|
||
, 🚥 👆 💚 📨 🍕 ℹ 👈 💪 🚫 🌐 🔢, 👆 💪 ✔️ 🏷 ⏮️ 🌐 🔢 ™ 📦 (⏮️ 🔢 💲 ⚖️ `None`).
|
||
|
||
🔬 ⚪️➡️ 🏷 ⏮️ 🌐 📦 💲 **ℹ** & 🏷 ⏮️ ✔ 💲 **🏗**, 👆 💪 ⚙️ 💭 🔬 [➕ 🏷](extra-models.md){.internal-link target=_blank}.
|
||
|
||
///
|