Making requests that paginate results
Now, we will compose and send an HTTP GET
request to retrieve all the drones. The new pagination settings will take effect and we will only retrieve the first page for the drones resource collection:
http GET :8000/drones/
The following is the equivalent curl
command:
curl -iX GET localhost:8000/drones/
The previous commands will compose and send an HTTP GET
request. The request specifies /drones/
, and therefore, it will match the '^drones/$'
regular expression and run the get
method for the views.DroneList
class-based view. The method executed in the generic view will use the new settings we added to enable the offset/limit pagination, and the result will provide us with the first four drone resources. However, the response body looks different than in the previous HTTP GET
requests we made to any resource collection. The following lines show the sample response that we will analyze in detail. Don't forget that the drones are being sorted by the name field...