model_dump(
self,
*,
mode: Literal['json', 'python'] | str = 'python',| Name | Type | Description |
|---|---|---|
mode | Literal['json', 'python'] | str | Default: 'python'The mode in which |
include | IncEx | None | Default: NoneA set of fields to include in the output. |
exclude | IncEx | None | Default: None |
context | Any | None | Default: None |
by_alias | bool | None | Default: None |
exclude_unset | bool | Default: False |
exclude_defaults | bool | Default: False |
exclude_none | bool | Default: False |
exclude_computed_fields | bool | Default: False |
round_trip | bool | Default: False |
warnings | bool | Literal['none', 'warn', 'error'] | Default: True |
fallback | Callable[[Any], Any] | None | Default: None |
serialize_as_any | bool | Default: False |
Usage docs: https://docs.pydantic.dev/2.4/concepts/serialization/#modelmodel_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
A set of fields to exclude from the output.
Additional context to pass to the serializer.
Whether to use the field's alias in the dictionary key if defined.
Whether to exclude fields that have not been explicitly set.
Whether to exclude fields that are set to their default value.
Whether to exclude fields that have a value of None.
Whether to exclude computed fields.
While this can be useful for round-tripping, it is usually recommended to use the dedicated
round_trip parameter instead.
If True, dumped values should be valid as input for non-idempotent types such as Json[T].
How to handle serialization errors. False/"none" ignores them, True/"warn" logs errors,
"error" raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
Whether to serialize fields with duck-typing serialization behavior.