Grokking Django
0% completed
Redirecting and Handling Responses in Django Views
HttpResponse("Hello") looks like a plain text response, but Django labels it as HTML. Its Content-Type header is text/html; charset=utf-8, because that is the default for every HttpResponse, whatever the body contains. A response is more than its body, and choosing the right response class or the right arguments sets the parts a browser or an API client acts on.
The Three Parts of a Response
Every response has a status code, headers and a body. HttpResponse takes the body as its first argument and sets the other two parts to defaults: status 200 and the content type
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%