Pydantic Cheatsheet 04 — Serialization

Cheatsheet: model_dump, exclude/include/exclude_none/exclude_unset, field_serializer, model_serializer.

May 14, 2026 · 2 min · 381 words · Manvendra Rajpoot

Pydantic v2 Textbook Ch. 4 — Serialization in Depth

Output side: model_dump, model_dump_json, field/model serializers, exclude/include, mode=python/json, by_alias.

May 9, 2026 · 3 min · 616 words · Manvendra Rajpoot

Pydantic Cheatsheet 05 — Discriminated Unions and Generics

Cheatsheet: discriminator field, callable Discriminator, Generic[T] models, recursive references.

May 14, 2026 · 2 min · 422 words · Manvendra Rajpoot

Pydantic v2 Textbook Ch. 5 — Nested Models, Generics, and Discriminated Unions

Composing models: nesting, generics with TypeVars, discriminated unions, recursive models.

May 9, 2026 · 3 min · 471 words · Manvendra Rajpoot

Pydantic Cheatsheet 06 — Custom Types and TypeAdapter

Cheatsheet: custom types via Annotated, GetCoreSchemaHandler, RootModel, TypeAdapter, dataclass integration.

May 14, 2026 · 3 min · 445 words · Manvendra Rajpoot

Pydantic v2 Textbook Ch. 6 — Custom Types and TypeAdapter

Custom types via Annotated, RootModel for primitive-typed root, TypeAdapter for arbitrary types, dataclass integration.

May 9, 2026 · 3 min · 595 words · Manvendra Rajpoot

Pydantic Cheatsheet 07 — Strict vs Lax Mode

Cheatsheet: lax default, strict per model / field / call, bool-is-int gotcha, JSON vs dict input.

May 14, 2026 · 2 min · 417 words · Manvendra Rajpoot

Pydantic v2 Textbook Ch. 7 — Strict Mode and Coercion

When Pydantic coerces vs raises: strict mode, per-field strict, lax/strict tradeoffs at API boundaries.

May 9, 2026 · 3 min · 581 words · Manvendra Rajpoot

Pydantic Cheatsheet 08 — Aliases (Input/Output Field Names)

Cheatsheet: alias variants, populate_by_name, AliasChoices for multi-alias, AliasPath for nested input.

May 14, 2026 · 2 min · 405 words · Manvendra Rajpoot

Pydantic v2 Textbook Ch. 8 — JSON Schema Generation

JSON Schema from Pydantic: model_json_schema, OpenAPI integration, custom schemas, examples.

May 9, 2026 · 3 min · 579 words · Manvendra Rajpoot