Using a web browser to work with our web service
Let's start browsing our RESTful Web Service. Open a web browser and enter http://localhost:8000/toys/
. The browser will compose and send a GET
request to http://localhost:8000/toys/
with text/html
as the desired content type and the returned HTML web page will be rendered.
Under the hood, the web service will compose and send an HTTP GET request to http://localhost:8000/toys/
with application/json
as the content type and the headers, and the JSON returned by this request will be rendered as part of the content of the web page. The following screenshot shows the rendered web page with the resource collection description, Toy List
:
When we work with the browsable API, Django uses the information about the allowed methods for a resource or resource collection to render the appropriate buttons to allow us to execute the related requests. In the previous screenshot, you will notice that there are two buttons on the right-hand side of the resource...