python
config_error
ai_generated
true
pydantic.errors.PydanticUserError: `orm_mode` is deprecated. Use `from_attributes` instead.
ID: python/fastapi-pydantic-v1-v2-migration-error
80%Fix Rate
88%Confidence
0Evidence
2025-10-22First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 2.x | active | — | — | — |
Root Cause
Code written for Pydantic v1 (`class Config: orm_mode = True`) runs under Pydantic v2, which renamed the setting.
generic中文
为 Pydantic v1 编写的代码(`class Config: orm_mode = True`)在 Pydantic v2 下运行,而 v2 重命名了该设置。
Workarounds
-
95% success
class UserOut(BaseModel): model_config = ConfigDict(from_attributes=True) id: int name: str -
85% success
Run `bump-pydantic` codemod: `pip install bump-pydantic && bump-pydantic .` to auto-migrate.
Dead Ends
Common approaches that don't work:
-
90% fail
FastAPI 0.100+ requires Pydantic v2; pip resolver errors.
-
85% fail
Config is ignored; from_orm/validation fails at runtime.