Guides
Pydantic Migration Guides
Exact-problem pages for the safe Pydantic v1 to v2 subset.
Problem pages
Exact-problem pages for the safe Pydantic v1 to v2 subset.
How to replace @validator with @field_validator in Pydantic v2Fix simple Pydantic validator migrations and keep signature-heavy cases out of the automatic path.How to move BaseSettings to pydantic-settings in Pydantic v2Fix BaseSettings migrations for Pydantic v2 and keep config cleanup inside the supported subset.How to convert Config to model_config in Pydantic v2Convert safe nested Config classes into model_config and refuse removed keys.How to replace validate_arguments with validate_call in Pydantic v2Fix validate_arguments migrations and keep the rewrite narrow enough to stay deterministic.How to replace @root_validator(pre=True) with @model_validator(mode="before")Migrate the supported pre root-validator subset in Pydantic v2 and keep the rest out of the automatic path.Why post root validators need manual review in Pydantic v2Understand why post root validators are outside the deterministic migration path.How to move pydantic.v1 imports onto pydantic in the safe Pydantic v2 subsetRewrite direct pydantic.v1 imports when the imported symbols stay inside the supported v2 subset.Why Config.fields is a manual-review case in Pydantic v2Config.fields was removed in Pydantic v2, so this is not a simple model_config rename.Why @validator(each_item=True) needs manual review in Pydantic v2Understand why validator(each_item=True) stays outside the deterministic migration path.Why configured @validate_arguments needs manual review in Pydantic v2Configured validate_arguments decorators are outside the current deterministic migration subset.How to replace Extra.forbid with extra='forbid' in Pydantic v2Migrate the Extra enum usage to string literal in model_config.How to replace schema_extra with json_schema_extra in Pydantic v2Migrate schema_extra in Config to json_schema_extra in model_config.How to replace orm_mode=True with from_attributes=True in Pydantic v2The orm_mode config key was renamed to from_attributes in Pydantic v2.Why Field(const=True) needs manual review in Pydantic v2Field(const=True) was removed in Pydantic v2. Use Literal types instead.Fix BaseSettings import errors in Pydantic v2Move BaseSettings imports to pydantic-settings when upgrading to Pydantic v2.Fix Pydantic v2 @validator deprecation warningsReplace simple @validator usage with @field_validator in the safe Pydantic v2 subset.Fix Pydantic v2 class Config deprecation warningsConvert safe class Config blocks into model_config with ConfigDict.