Search Options

Results per page
Sort
Preferred Languages
Advance

Results 41 - 50 of 127 for Model (3.91 sec)

  1. docs/zh/docs/advanced/response-cookies.md

    ```Python hl_lines="1  8-9"
    {!../../../docs_src/response_cookies/tutorial002.py!}
    ```
    
    而且你还可以根据你的需要响应不同的对象,比如常用的 `dict`,数据库model等。
    
    如果你定义了 `response_model`,程序会自动根据`response_model`来过滤和转换你响应的对象。
    
    **FastAPI** 会使用这个 *临时* 响应对象去装在这些cookies信息 (同样还有headers和状态码等信息), 最终会将这些信息和通过`response_model`转化过的数据合并到最终的响应里。
    
    你也可以在depend中定义`Response`参数,并设置cookie和header。
    
    ## 直接响应 `Response`
    
    你还可以在直接响应`Response`时直接创建cookies。
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Aug 18 16:09:38 GMT 2022
    - 2.1K bytes
    - Viewed (0)
  2. docs/em/docs/advanced/dataclasses.md

    !!! info
        ✔️ 🤯 👈 🎻 💪 🚫 🌐 Pydantic 🏷 💪.
    
        , 👆 5️⃣📆 💪 ⚙️ Pydantic 🏷.
    
        ✋️ 🚥 👆 ✔️ 📚 🎻 🤥 🤭, 👉 👌 🎱 ⚙️ 👫 🏋️ 🕸 🛠️ ⚙️ FastAPI. 👶
    
    ## 🎻 `response_model`
    
    👆 💪 ⚙️ `dataclasses` `response_model` 🔢:
    
    ```Python hl_lines="1  7-13  19"
    {!../../../docs_src/dataclasses/tutorial002.py!}
    ```
    
    🎻 🔜 🔁 🗜 Pydantic 🎻.
    
    👉 🌌, 🚮 🔗 🔜 🎦 🆙 🛠️ 🩺 👩‍💻 🔢:
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Fri Mar 22 01:42:11 GMT 2024
    - 3.5K bytes
    - Viewed (0)
  3. docs/zh/docs/advanced/response-change-status-code.md

    但你仍然希望能够使用`response_model`过滤和转换你返回的数据。
    
    对于这些情况,你可以使用一个`Response`参数。
    
    ## 使用 `Response` 参数
    
    你可以在你的*路径操作函数*中声明一个`Response`类型的参数(就像你可以为cookies和头部做的那样)。
    
    然后你可以在这个*临时*响应对象中设置`status_code`。
    
    ```Python hl_lines="1  9  12"
    {!../../../docs_src/response_change_status_code/tutorial001.py!}
    ```
    
    然后你可以像平常一样返回任何你需要的对象(例如一个`dict`或者一个数据库模型)。如果你声明了一个`response_model`,它仍然会被用来过滤和转换你返回的对象。
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Sat Jun 10 20:30:28 GMT 2023
    - 1.4K bytes
    - Viewed (0)
  4. docs/em/docs/tutorial/handling-errors.md

    `RequestValidationError` 🎧-🎓 Pydantic <a href="https://docs.pydantic.dev/latest/concepts/models/#error-handling" class="external-link" target="_blank">`ValidationError`</a>.
    
    **FastAPI** ⚙️ ⚫️ 👈, 🚥 👆 ⚙️ Pydantic 🏷 `response_model`, &amp; 👆 💽 ✔️ ❌, 👆 🔜 👀 ❌ 👆 🕹.
    
    ✋️ 👩‍💻/👩‍💻 🔜 🚫 👀 ⚫️. ↩️, 👩‍💻 🔜 📨 "🔗 💽 ❌" ⏮️ 🇺🇸🔍 👔 📟 `500`.
    
    ⚫️ 🔜 👉 🌌 ↩️ 🚥 👆 ✔️ Pydantic `ValidationError` 👆 *📨* ⚖️ 🙆 👆 📟 (🚫 👩‍💻 *📨*), ⚫️ 🤙 🐛 👆 📟.
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Fri Mar 22 01:42:11 GMT 2024
    - 8.3K bytes
    - Viewed (0)
  5. pyproject.toml

    ]
    
    [tool.coverage.run]
    parallel = true
    source = [
        "docs_src",
        "tests",
        "fastapi"
    ]
    context = '${CONTEXT}'
    omit = [
        "docs_src/response_model/tutorial003_04.py",
        "docs_src/response_model/tutorial003_04_py310.py",
    ]
    
    [tool.ruff.lint]
    select = [
        "E",  # pycodestyle errors
        "W",  # pycodestyle warnings
        "F",  # pyflakes
        "I",  # isort
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu May 02 22:37:31 GMT 2024
    - 9.3K bytes
    - Viewed (0)
  6. docs/zh/docs/advanced/dataclasses.md

    数据类的和运作方式与 Pydantic 模型相同。实际上,它的底层使用的也是 Pydantic。
    
    !!! info "说明"
    
        注意,数据类不支持 Pydantic 模型的所有功能。
    
        因此,开发时仍需要使用 Pydantic 模型。
    
        但如果数据类很多,这一技巧能给 FastAPI 开发 Web API 增添不少助力。🤓
    
    ## `response_model` 使用数据类
    
    在 `response_model` 参数中使用 `dataclasses`:
    
    ```Python hl_lines="1  7-13  19"
    {!../../../docs_src/dataclasses/tutorial002.py!}
    ```
    
    本例把数据类自动转换为 Pydantic 数据类。
    
    API 文档中也会显示相关概图:
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Sat Mar 30 22:44:14 GMT 2024
    - 3.8K bytes
    - Viewed (0)
  7. docs/de/docs/tutorial/path-params.md

    ```Python hl_lines="17"
    {!../../../docs_src/path_params/tutorial005.py!}
    ```
    
    #### *Enum-Wert* erhalten
    
    Den tatsächlichen Wert (in diesem Fall ein `str`) erhalten Sie via `model_name.value`, oder generell, `ihr_enum_member.value`:
    
    ```Python hl_lines="20"
    {!../../../docs_src/path_params/tutorial005.py!}
    ```
    
    !!! tip "Tipp"
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Sat Mar 30 20:28:59 GMT 2024
    - 10.3K bytes
    - Viewed (0)
  8. docs/en/docs/advanced/response-headers.md

    And if you declared a `response_model`, it will still be used to filter and convert the object you returned.
    
    **FastAPI** will use that *temporal* response to extract the headers (also cookies and status code), and will put them in the final response that contains the value you returned, filtered by any `response_model`.
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Jan 11 16:31:18 GMT 2024
    - 2.2K bytes
    - Viewed (0)
  9. docs/ja/docs/tutorial/handling-errors.md

    `RequestValidationError`はPydanticの<a href="https://docs.pydantic.dev/latest/concepts/models/#error-handling" class="external-link" target="_blank">`ValidationError`</a>のサブクラスです。
    
    **FastAPI** は`response_model`でPydanticモデルを使用していて、データにエラーがあった場合、ログにエラーが表示されるようにこれを使用しています。
    
    しかし、クライアントやユーザーはそれを見ることはありません。その代わりに、クライアントはHTTPステータスコード`500`の「Internal Server Error」を受け取ります。
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Fri Mar 22 01:42:11 GMT 2024
    - 11.8K bytes
    - Viewed (0)
  10. docs/en/docs/advanced/response-directly.md

    # Return a Response Directly
    
    When you create a **FastAPI** *path operation* you can normally return any data from it: a `dict`, a `list`, a Pydantic model, a database model, etc.
    
    By default, **FastAPI** would automatically convert that return value to JSON using the `jsonable_encoder` explained in [JSON Compatible Encoder](../tutorial/encoder.md){.internal-link target=_blank}.
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Sat Aug 29 14:02:58 GMT 2020
    - 3K bytes
    - Viewed (0)
Back to top