From the course: Building React and Django Apps

Creating a ViewSet with Django

From the course: Building React and Django Apps

Start my 1-month free trial

Creating a ViewSet with Django

- [Instructor] We're going to create a view set for the tour packages by reusing the existing package serializer. We already have a view set for creating and updating packages, but that's for administrative users to use. What we want is a public list of packages for anyone to access. We create a public package view set, and with the permission classes, set to token has scope. All users will have permission to access the list and they will only need the read scope on their Oauth token. All packages will be returned from this API end point in descending order by price and here's where we reuse the package serializer class. Now in the URLs configuration, we add a new route to the Django rest framework default router.

Contents