December 2018
Beginner to intermediate
796 pages
19h 54m
English
Now, we will compose and send an HTTP request to delete an existing toy, specifically, the last toy we added. As in our last HTTP request, we have to check the value assigned to pk in the previous response and replace 4 in the command with the returned value:
http DELETE :8000/toys/4
The following is the equivalent curl command:
curl -iX DELETE localhost:8000/toys/4
The previous commands will compose and send the following HTTP request: DELETE http://localhost:8000/toys/4. The request has a number after /toys/, and therefore, it will match the '^toys/(?P<pk>[0-9]+)$' regular expression and run the views.toy_detail function, that is, the toy_detail function declared within the toys/views.py file. The function ...
Read now
Unlock full access