# Werkzeug路由错误：无法为端点'login'构建URL

- **ID:** `python/werkzeug-builderror-could-not-build-url`
- **领域:** python
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

端点名称不存在或缺少必需的URL参数。

## 版本兼容性

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

## 解决方案

1. **Check endpoint name and provide all parameters** (90% 成功率)
   ```
   url_for('login', next='/dashboard')
   ```
2. **List all endpoints with app.url_map** (85% 成功率)
   ```
   print(app.url_map)
   ```

## 无效尝试

- **Assuming endpoint name is the function name without decorator** — Flask endpoint defaults to function name, but can be overridden. (60% 失败率)
- **Missing required parameter in url_for** — If route has path parameters, they must be provided. (80% 失败率)
