Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django Tutorial: name 'HttpResponse' is not defined

Tags:

python

django

I am learning Django via their tutorial for getting started. I have looked at other Django Tutorial errors and did not see this one (although I did not search every listing).

I have made the changes to mysite/urls.py and polls/urls.py exactly as they demonstrate and I have run the server command:

python manage.py runserver

I get the following error: enter image description here

Since I am new to Django, I do not know what is going on. Please help.

like image 250
SumNeuron Avatar asked May 25 '17 16:05

SumNeuron


People also ask

What is Django httpresponsenotallowed?

HttpResponseNotAllowed is a subclass of HttpResponse that returns a HTTP response with 405 status. 1. Django HttpResponseNotAllowed with examples

What is httpresponse?

HttpResponse is a class thats return an http response, and in ths tutorial, we'll learn how to use HttpResponse with simple examples. 1. HttpResponse

What is a httprequest in Django?

– Django HttpResponse Explained As we mentioned earlier, a Django view takes a web request and returns a web response. After the request is captured, Django creates an HttpRequest object with associated metadata that is then processed by middlewares and backend logic.

How to return JSON data from Django REST API?

Often, and especially if you are designing a REST API, you’ll have to return JSON data to the client. Django has a special HttpResponse subclass called JsonResponse that makes this easy for you. 3. Use HttpResponse to return data as a File attachment


1 Answers

from django.http import HttpResponse

in your views file at the top

like image 126
Exprator Avatar answered Sep 20 '22 12:09

Exprator