From the course: Building RESTful Web APIs with Django
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Connecting a DestroyAPIView to the router
From the course: Building RESTful Web APIs with Django
Connecting a DestroyAPIView to the router
- [Instructor] Let's connect the destroy product API view to the router, so that we can start using it in our API. In the URL's configuration we add a new URL path with the lookup field so that we can destroy a product using the ProductDestroy API view. With the server running let's try this out on the browser. First we find the ID of an existing product, and then we can delete the product. We click the destroy button and confirm the action. We can also delete products through a curl command on the command line. Let's create a new product and then delete it. We use the POST method to create the product as we did before. The product is created, so now we can use the returned ID and delete it. So, we use the DELETE method with our URL for product deletion. And then hit enter, and it looks like the product is deleted now. And that's how we delete a product through the browser, and through the command line using the REST API.
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
(Locked)
Creating a CreateAPIView subclass2m 53s
-
(Locked)
Connecting a CreateAPIView to the router2m 1s
-
(Locked)
Creating a DestroyAPIView subclass2m 18s
-
(Locked)
Connecting a DestroyAPIView to the router2m 7s
-
(Locked)
Creating an UpdateAPIView subclass3m 35s
-
(Locked)
Connecting an UpdateAPIView to the router1m 22s
-
(Locked)
-
-
-