Django Tutorial: name 'HttpResponse' is not defined

from django.http import HttpResponse add this line on the top of polls/views.py file. I am new too, and had the same error. good Luck and i see u around.


from django.http import HttpResponse

in your views file at the top


in your polls/views.py

By default is :

from django.shortcuts import render

change to:

from django.shortcuts import render,HttpResponse

this will call the HttpResponse class


Put this import in your poll/views.py before using HttpResponse.

from django.http import HttpResponse

Tags:

Python

Django