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.
Creating an UpdateAPIView subclass
From the course: Building RESTful Web APIs with Django
Creating an UpdateAPIView subclass
- [Narrator] Right now we can delete individual products. That happens through the DestroyAPIView, but what if we wanted to retrieve an individual product's data? We would have to create a new RetrieveAPIView to handle the Get HTTP method. And what if we also wanted to update and individual products data, whether fully updating it or partially updating it? We would again have to create another APIView this time using UpdateAPIView. But why do all of that when we can just use Django rest frameworks generic view that combines all of those. With the RetrieveUpdateDestroyAPIView we cam reuse code and configuration. For example, the serialiszer_class or queryset and other configuration options for generic views. And on top of that we can use One URL to handle multiple HTTP methods. To allow for this combination of actions we're going to re-factor the ProductDestroyAPIView into the RetrieveUPdateDestroyAPIView. We need to import it (typing) and then re-factor the ProductDestroy class. We…
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)
-
-
-