Browsing the API with resources and relationships
We will take advantage of the browsable API feature that we introduced in Chapter 5, Understanding and Customizing the Browsable API Feature, with our new web service. Let's start browsing our new RESTful Web Service. Open a web browser and enter http://localhost:8000
. The browser will compose and send a GET
request to /
with text/html
as the desired content type, and the returned HTML web page will be rendered.
The request will end up executing the GET
method defined in the ApiRoot
class within the views.py
file. The following screenshot shows the rendered web page with the resource description Api Root
:
The Api Root
renders the following hyperlinks:
http://localhost:8000/drone-categories/
: The collection of drone categorieshttp://localhost:8000/drones/
: The collection of droneshttp://localhost:8000/pilots/
: The collection of pilotshttp://localhost:8000/competitions/
: The collection of competitions
We can easily access each resource collection...