computed_field
ComputedFields are properties of a model or dataclass that are included in serialization.
def computed_field(
property_name: str,
return_schema: CoreSchema,
alias: str | None = None,
serialization_exclude_if: Callable[[Any], bool] | None = None,
metadata: dict[str, Any] | None = None
) - > ComputedField
ComputedFields are properties of a model or dataclass that are included in serialization.
Parameters
| Name | Type | Description |
|---|---|---|
| property_name | str | The name of the property on the model or dataclass |
| return_schema | CoreSchema | The schema used for the type returned by the computed field |
| alias | `str | None` = None |
| serialization_exclude_if | `Callable[[Any], bool] | None` = None |
| metadata | `dict[str, Any] | None` = None |
Returns
| Type | Description |
|---|---|
ComputedField | A dictionary configuration object representing the computed field schema for pydantic-core |