# pydantic.errors.PydanticUserError: 字段名 'model_config' 与父类 'BaseModel' 中的属性冲突

- **ID:** `python/pydantic-model-field-name-shadowing`
- **领域:** python
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

自定义字段名与 BaseModel 的保留属性（如 model_config、model_fields、model_dump）冲突。

## 版本兼容性

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

## 解决方案

1. **** (95% 成功率)
   ```
   from pydantic import BaseModel, Field
class Settings(BaseModel):
    config: dict = Field(alias="model_config")
   ```
2. **** (90% 成功率)
   ```
   class Settings(BaseModel):
    app_config: dict = Field(serialization_alias="model_config")
   ```

## 无效尝试

- **** — BaseModel is from the Pydantic library; you cannot rename its attributes without forking. (95% 失败率)
- **** — protected_namespaces controls the model_ prefix warning, not reserved attribute collisions. (80% 失败率)
- **** — The Python attribute name still shadows the parent, so the error persists at class creation. (70% 失败率)
