From the course: Building React and Django Apps
Deleting an item using React and Django
From the course: Building React and Django Apps
Deleting an item using React and Django
- [Instructor] Right now the wishlist functionality only allows adding items to the wishlist. We're going to change this toggle a wishlist method, to allow deleting wishlist items. In the service API class, we update the wishlist delete method, we reuse the configuration, for sending http requests, which includes the ilog token, and then we return the resulting promise from the Axios, delete method. Now we need to override the destroy method of the wishlist item view set, on the Django side of things. We use pk, the primary key, as the package id, and then we search for the wishlist item, we delete the item, we delete the item from cache, and then we return a two hundred okay response with a short message. Now we run the development servers, we open up the network panel network panel, the dev tools, and so when we click to add a wishlist item, we see the request go through, the icon changes, we can see the response there, and then when we delete the item from the wishlist, we see the corresponding delete method. We can also check the Django admin, to see what wishlist items there are.
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
-
-
-
-
Creating a ViewSet with Django1m 2s
-
(Locked)
Displaying a list of items with React2m 47s
-
Deleting an item using React and Django1m 49s
-
(Locked)
Partially updating an item using React1m 50s
-
(Locked)
Pagination with Django38s
-
(Locked)
Pagination with React3m 31s
-
(Locked)
Filtering with Django1m 56s
-
(Locked)
Filtering with React4m 44s
-
-
-
-
-