Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cannot import name HttpResponse

Tags:

python

django

views.py

from django import HttpResponse

def hello(request):
    return HttpResponse("Hello world ! ")

Request Method: GET
Request URL:    http://127.0.0.1:8000/hello/
Django Version: 1.3.1
Exception Type: ImportError
Exception Value:    
cannot import name HttpResponse
like image 227
fuhao715 Avatar asked Oct 21 '11 05:10

fuhao715


2 Answers

You can try this: from django.http import HttpResponse

like image 162
juankysmith Avatar answered Oct 03 '22 08:10

juankysmith


You are importing from wrong location

django.http this is right location from django.http import HttpResponse

like image 40
Shashi Avatar answered Oct 03 '22 06:10

Shashi