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 an APIView to a route

Connecting an APIView to a route

From the course: Building RESTful Web APIs with Django

Start my 1-month free trial

Connecting an APIView to a route

- [Instructor] Presently we are taking a look at how to connect the product list API view to a URL route. We start by opening up the URL's Configuration for the web app and we see some URLs are already in there. And now we have to connect our List API view, the Product List API view, to a route. And we are going to use api_views.ProductList.as_view. And we have to import store.api_views. That's all there is to it. This will let us send a GET request to the API V1 product's URL, and get back a JSON response that shows a list of products. To run the server, you have to be in the top level directory. So we activate virtualenv, and then we run the server. Now here's a cool way of testing to make sure the product's List API view is working. We switch to the browser, and we can actually try out the REST API, from the browser. This is what makes Django REST framework different from all other REST API frameworks. If you add a docstring to your API view subclass, it will actually show up in…

Contents