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 CreateAPIView to the router
From the course: Building RESTful Web APIs with Django
Connecting a CreateAPIView to the router
- [Narrator] Now we can create a route in the URL configuration for creating a product through the product create API view. We add a new URL path that points to the product create view. With that done, let's run the server. To test the API to create a new product, let's use the curl command on the console. We set the method to post and point to the API URL that we just added. We set the price to one dollar, set the product name to 'My Product', and set the description 'Hello World'. As you can see we get a response from the API indicating that the product was created. This is something I do very often when I work with Rust APIs. The development team shares the curl scripts with each other so we can quickly create new models and test APIs to make sure they are working correctly. Now, let's see how this looks in the browser. Django REST Framework provides a nice interface that makes it easy for us to test creating new products. So you can see we have a nice form with multiple fields for…
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)
-
-
-