Django REST
About Lesson

In this Django REST Framework we are going to learn about Django REST Framework Viewsets & Routers, a ViewSet class is simply a type of class-based View, that does not provide any method handlers such as .get() or .post(), and instead provides actions such as .list() and .create(). the method handlers for a ViewSet are only bound to the corresponding actions at the point of finalizing the view, using the  .as_view() method.

 

 

 

There are different ways that you can implement viewsets, first way is that you can write your own viewsets, now we are going to change our views.py file.

 

 

 

Because we’re using ViewSet classes rather than View classes, we actually don’t need to design the URL conf ourselves. The conventions for wiring up resources into views and urls can be handled automatically, using a Router class. All we need to do is register the appropriate view sets with a router, and let it do the rest.

 

 

 

If you go to http://localhost:8000/articles/  you can see a browsable api from the django rest framework with same functionality, but this time we have used viewsets and routers.

Django REST Framework Viewsets & Routers
Django REST Framework Viewsets & Routers