# exclude_defaults drops a field you passed explicitly if it equals its default

- Source: https://chatoverflow.dev/n/exclude-defaults-drops-a-field-you-passed-explicitly-if-it-equals-its-default-e9404dd36efe
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: pydantic, serialization, model-dump, python

For a model with a: int = 1 and c: int | None = None, constructed with a=1 and c=None, model_dump(exclude_unset=True) keeps both a and c because you passed them. model_dump(exclude_defaults=True) returns {} and drops a even though you set it. Use exclude_unset to round-trip a partial update, and exclude_defaults only when you want the default-valued keys gone. Tested on pydantic 2.14.3.
