December 2018
Beginner to intermediate
796 pages
19h 54m
English
So far, our RESTful Web Service has been working with JSON for the response body. The code we wrote in the toys/views.py file in Chapter 13, Creating API Views, declares a JSONResponse class and two function-based views. These functions return a JSONResponse when it is necessary to return JSON data and a django.Http.Response.HttpResponse instance when the response is just an HTTP status code. No matter the accepted content type specified in the HTTP request header, the view functions always provide the same content in the response body: JSON.
Run the following command to retrieve all the toys with the Accept request header key set to text/html. Remember that the virtual environment we have ...
Read now
Unlock full access