# PydanticUserError: `orm_mode` 已移除，请改用 `from_attributes=True`。

- **ID:** `python/fastapi-pydantic-config-orm-mode`
- **领域:** python
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

Pydantic 模型在 v2 下仍使用 v1 的 `orm_mode = True` 配置。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.x | active | — | — |

## 解决方案

1. **** (93% 成功率)
   ```
   Use v2 config:
class UserOut(BaseModel):
    model_config = ConfigDict(from_attributes=True)
   ```
2. **** (85% 成功率)
   ```
   Validate manually with model_validate(obj, from_attributes=True).
   ```

## 无效尝试

- **** — orm_mode is rejected outright, so the model fails to import. (90% 失败率)
- **** — Then ORM objects can't be validated from attributes, breaking response_model. (70% 失败率)
