Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 94 for exclude (0.15 sec)

  1. docs/zh/docs/tutorial/response-model.md

    ### `response_model_include` 和 `response_model_exclude`
    
    你还可以使用*路径操作装饰器*的 `response_model_include` 和 `response_model_exclude` 参数。
    
    它们接收一个由属性名称 `str` 组成的 `set` 来包含(忽略其他的)或者排除(包含其他的)这些属性。
    
    如果你只有一个 Pydantic 模型,并且想要从输出中移除一些数据,则可以使用这种快捷方法。
    
    !!! tip
        但是依然建议你使用上面提到的主意,使用多个类而不是这些参数。
    
        这是因为即使使用 `response_model_include` 或 `response_model_exclude` 来省略某些属性,在应用程序的 OpenAPI 定义(和文档)中生成的 JSON Schema 仍将是完整的模型。
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Fri Mar 22 01:42:11 GMT 2024
    - 7.9K bytes
    - Viewed (0)
  2. docs/ja/docs/tutorial/response-model.md

    !!! info "情報"
        以下も使用することができます:
    
        * `response_model_exclude_defaults=True`
        * `response_model_exclude_none=True`
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Fri Mar 22 01:42:11 GMT 2024
    - 9.3K bytes
    - Viewed (0)
  3. docs/en/docs/tutorial/response-model.md

        They can be a list (`[]`), a `float` of `10.5`, etc.
    
    ### `response_model_include` and `response_model_exclude`
    
    You can also use the *path operation decorator* parameters `response_model_include` and `response_model_exclude`.
    
    They take a `set` of `str` with the name of the attributes to include (omitting the rest) or to exclude (including the rest).
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 19:53:19 GMT 2024
    - 17.9K bytes
    - Viewed (0)
  4. docs/zh/docs/tutorial/body-updates.md

        `PATCH` 没有 `PUT` 知名,也怎么不常用。
    
        很多人甚至只用 `PUT` 实现部分更新。
    
        **FastAPI** 对此没有任何限制,可以**随意**互换使用这两种操作。
    
        但本指南也会分别介绍这两种操作各自的用途。
    
    ### 使用 Pydantic 的 `exclude_unset` 参数
    
    更新部分数据时,可以在 Pydantic 模型的 `.dict()` 中使用 `exclude_unset` 参数。
    
    比如,`item.dict(exclude_unset=True)`。
    
    这段代码生成的 `dict` 只包含创建 `item` 模型时显式设置的数据,而不包括默认值。
    
    然后再用它生成一个只含已设置(在请求中所发送)数据,且省略了默认值的 `dict`:
    
    ```Python hl_lines="34"
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 19:53:19 GMT 2024
    - 3.6K bytes
    - Viewed (0)
  5. docs/de/docs/tutorial/response-model.md

    !!! info
        Sie können auch:
    
        * `response_model_exclude_defaults=True`
        * `response_model_exclude_none=True`
    
        verwenden, wie in der <a href="https://docs.pydantic.dev/1.10/usage/exporting_models/#modeldict" class="external-link" target="_blank">Pydantic Dokumentation</a> für `exclude_defaults` und `exclude_none` beschrieben.
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Sat Mar 30 20:26:58 GMT 2024
    - 19.9K bytes
    - Viewed (0)
  6. docs/em/docs/tutorial/response-model.md

    !!! info
        👆 💪 ⚙️:
    
        * `response_model_exclude_defaults=True`
        * `response_model_exclude_none=True`
    
        🔬 <a href="https://docs.pydantic.dev/latest/concepts/serialization/#modeldict" class="external-link" target="_blank">Pydantic 🩺</a> `exclude_defaults` &amp; `exclude_none`.
    
    #### 📊 ⏮️ 💲 🏑 ⏮️ 🔢
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Fri Mar 22 01:42:11 GMT 2024
    - 16K bytes
    - Viewed (0)
  7. fastapi/applications.py

                response_model_include=response_model_include,
                response_model_exclude=response_model_exclude,
                response_model_by_alias=response_model_by_alias,
                response_model_exclude_unset=response_model_exclude_unset,
                response_model_exclude_defaults=response_model_exclude_defaults,
                response_model_exclude_none=response_model_exclude_none,
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Tue Apr 02 02:48:51 GMT 2024
    - 172.2K bytes
    - Viewed (0)
  8. tests/test_skip_defaults.py

    )
    def get_exclude_defaults() -> ModelDefaults:
        return ModelDefaults(x=None, y="y")
    
    
    @app.get(
        "/exclude_none", response_model=ModelDefaults, response_model_exclude_none=True
    )
    def get_exclude_none() -> ModelDefaults:
        return ModelDefaults(x=None, y="y")
    
    
    @app.get(
        "/exclude_unset_none",
        response_model=ModelDefaults,
        response_model_exclude_unset=True,
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Jul 07 17:12:13 GMT 2023
    - 2K bytes
    - Viewed (0)
  9. fastapi/routing.py

                    value,
                    include=include,
                    exclude=exclude,
                    by_alias=by_alias,
                    exclude_unset=exclude_unset,
                    exclude_defaults=exclude_defaults,
                    exclude_none=exclude_none,
                )
    
            return jsonable_encoder(
                value,
                include=include,
                exclude=exclude,
                by_alias=by_alias,
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Tue Apr 02 02:48:51 GMT 2024
    - 170.1K bytes
    - Viewed (0)
  10. fastapi/encoders.py

            obj_dict = _model_dump(
                obj,
                mode="json",
                include=include,
                exclude=exclude,
                by_alias=by_alias,
                exclude_unset=exclude_unset,
                exclude_none=exclude_none,
                exclude_defaults=exclude_defaults,
            )
            if "__root__" in obj_dict:
                obj_dict = obj_dict["__root__"]
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 21:56:59 GMT 2024
    - 10.8K bytes
    - Viewed (0)
Back to top