[Django]-Delete/Destroy/Update list using Django REST API View

6👍

The principle of REST is to follow HTTP.

If you make something like “…url../example?delete=5” you would make GET request.
GET is not for deleting, updating, creating.
If you send GET request, it will retrieve, if you send PUT request it will update. The verbs are not part of the URL, so what you want to do with the URL parameters is not REST at all.

If the browsable API is not enough, you can check also some other tools. I use the chrome-extension REST Console:

https://chrome.google.com/webstore/detail/rest-console/cokgbflfommojglbmbpenpphppikmonn?hl=en

You can use curl in the bash to send different requests. For python there is a very nice library called requests:

http://docs.python-requests.org/en/latest/

👤cezar

5👍

If you use a default router and a ModelViewSet you just have to make a request to the API using the HTTP methods to update or delete respectively. Yo can also override the default methods list(), retrieve(), create(), update(), and destroy(), provided by default.

For more information see here.

Leave a comment