You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3.2 KiB

💪 - ℹ

⏮️ PUT

🏬 👆 💪 ⚙️ 🇺🇸🔍 PUT 🛠️.

👆 💪 ⚙️ jsonable_encoder 🗜 🔢 💽 📊 👈 💪 🏪 🎻 ( ⏮️💽). 🖼, 🏭 datetime str.

{* ../../docs_src/body_updates/tutorial001.py hl[30:35] *}

PUT ⚙️ 📨 💽 👈 🔜 💽.

🔃

👈👈 🚥 👆 💚🏬 bar ⚙️ PUT ⏮️ 💪 ⚗:

{
    "name": "Barz",
    "price": 3,
    "description": None,
}

↩️ 🚫 🔌 🏪 🔢 "tax": 20.2, 🔢 🏷 🔜 🔢 💲 "tax": 10.5.

& 📊 🔜 🖊 ⏮️ 👈 "🆕" tax 10.5.

🍕⏮️ PATCH

👆 💪 ⚙️ 🇺🇸🔍 PATCH 🛠️ 🍕💽.

👉👈 👆 💪 📨 🕴 💽 👈 👆 💚 ℹ, 🍂 🎂 🐣.

/// 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).

🔬 ➡️ 🏷 ⏮️ 🌐 📦 💲 & 🏷 ⏮️💲 🏗, 👆 💪 ⚙️ 💭 🔬 ➕ 🏷{.internal-link target=_blank}.

///