# TypeError at /api/users/abc/ Expected 'int' but received 'str'

- **ID:** `python/django-url-parameter-type`
- **Domain:** python
- **Category:** type_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

URL 路径参数未转换为整数，而视图期望整数类型

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.2 | active | — | — |
| 4.0 | active | — | — |
| 5.0 | active | — | — |

## Workarounds

1. **在 URL 模式中使用 int 转换器** (100% success)
   ```
   path('users/<int:id>/', views.user_detail)
   ```
2. **在视图中安全转换** (90% success)
   ```
   def user_detail(request, id): id = int(id) if isinstance(id, str) else id
   ```

## Dead Ends

- **在视图中用 int() 强制转换** — 如果字符串不是数字，int() 会抛出 ValueError (50% fail)
- **修改 URL 模式使用字符串类型** — 可能破坏其他依赖整数的逻辑 (40% fail)
