python
type_error
ai_generated
true
'HttpResponse'对象不可调用在/home/
'HttpResponse' object is not callable at /home/
ID: python/django-httpresponse-not-callable
80%修复率
85%置信度
0证据数
2024-05-20首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.x | active | — | — | — |
根因分析
返回HttpResponse实例但意外地将其作为函数调用。
English
Returning an HttpResponse instance but accidentally calling it as a function in the view.
解决方案
-
95% 成功率 Return instance without extra parentheses
return HttpResponse('Hello') -
90% 成功率 Use render shortcut
return render(request, 'template.html', context)
无效尝试
常见但无效的做法:
-
Using parentheses after HttpResponse
90% 失败
HttpResponse() returns object, but extra () tries to call it again.
-
Misunderstanding function vs class
70% 失败
View should return instance, not call it.