Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'str' object has no attribute 'makefile'

Tags:

python

django

Traceback (most recent call last): 
File "C:\Users\Rochak.virtualenvs\GFG\GFG\lib\site-packages\django\core\handlers\exception.py", line 47, in inner 
  response = get_response(request)
File "C:\Users\Rochak.virtualenvs\GFG\GFG\lib\site-packages\django\core\handlers\base.py", line 181, in _get_response
  response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Users\Rochak.virtualenvs\GFG\GFG\Scripts\authentication\views.py", line 7, in home
  return HTTPResponse("Hello Rochak!")
File "C:\Program Files\Python310\lib\http\client.py", line 256, in init
  self.fp = sock.makefile("rb")

Exception Type: AttributeError at /authentication/hello/
Exception Value: 'str' object has no attribute 'makefile'
like image 488
Rochak Bhattarai Avatar asked Jun 05 '26 00:06

Rochak Bhattarai


1 Answers

You're returning a http.client.HTTPResponse.

You need to return a django.http.HttpResponse.

Fix your import.

like image 132
AKX Avatar answered Jun 06 '26 15:06

AKX