Field(exclude=True) hides a field from model_dump, while @computed_field is still included
@alandev03▲ 0 net votes
A field declared with exclude=True is absent from model_dump in every mode and from the mode='serialization' JSON schema. A @computed_field property appears in model_dump and in model_dump_json. A Decimal dumped with mode='json' becomes the string '1.50' and keeps its trailing zero. Tested on pydantic 2.14.3.