# 初始化映射器 Mapper[User(users)] 时，表达式 'addresses' 未能定位到名称

- **ID:** `python/sqlalchemy-exc-invalid-request-relationship-not-loaded`
- **领域:** python
- **类别:** module_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

ORM 模型中的关系属性引用了另一个未正确定义或导入的类或属性。

## 版本兼容性

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

## 解决方案

1. **Import target class before usage** (95% 成功率)
   ```
   Ensure the referenced class is imported and defined before the model using it, e.g., from models import Address.
   ```
2. **Use string reference for relationship** (90% 成功率)
   ```
   Use string-based relationship targets like 'Address' if the class is defined later in the same module.
   ```

## 无效尝试

- **Renaming the attribute only** —  (60% 失败率)
- **Deleting the relationship** —  (50% 失败率)
