# Werkzeug 路由异常：无法为端点 'auth.login' 构建 URL。您是指 'login' 吗？

- **ID:** `python/flask-url-for-external-endpoint`
- **领域:** python
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

在 url_for 中使用了不存在的端点名称，可能因为蓝图前缀错误或函数名拼写错误。

## 版本兼容性

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

## 解决方案

1. **** (90% 成功率)
   ```
   from flask import Blueprint, url_for
auth_bp = Blueprint('auth', __name__)
@auth_bp.route('/login')
def login(): ...
app.register_blueprint(auth_bp)
# 使用 url_for('auth.login')
   ```
2. **** (85% 成功率)
   ```
   print(app.view_functions.keys())
   ```

## 无效尝试

- **** — 如果蓝图端点实际为 'auth.login'，使用 'login' 会继续报错。 (60% 失败率)
- **** — 如果蓝图未注册或名称错误，仍然无法构建。 (70% 失败率)
