We can take advantage of the browsable API to easily test filter, search, and order features through a web browser. Open a web browser and enter http://localhost:8000/player-scores/
. In case you use another computer or device to run the browser, replace localhost
with the IP of the computer that is running the Django development server. The browsable API will compose and send a GET
request to /player-scores/
and will display the results of its execution, that is, the headers and the JSON player scores list. You will notice that there is a new Filters button located on the left-hand side of the OPTIONS button.
Click on Filters and the browsable API will display the Filters dialog box with the appropriate controls for each filter that you can apply below Field Filters and the different ordering options below Ordering. The following screenshot shows the Filters dialog box:
Both the Player name and Game name dropdowns will only include the related player's and game's names that have registered scores because we used the AllValuesFilter
class for both filters. After we enter all the values for the filters, we can select the desired ordering option or click Submit. The browsable API will compose and send the appropriate HTTP request and will render a web page with the results of its execution. The results will include the HTTP request that was made to the Django server. The following screenshot shows an example of the result of executing the next request, that is, the request we built using the browsable API:
GET /player-scores/?score=&from_score_date=&to_score_date=&min_score=30000&max_score=40000&player_name=Brandon&game_name=PvZ+Garden+Warfare+4
3.15.137.75