From the course: Building React and Django Apps

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Handling creating models with Django REST framework

Handling creating models with Django REST framework

From the course: Building React and Django Apps

Start my 1-month free trial

Handling creating models with Django REST framework

- [Instructor] We're going to be creating a new view set so that we can save the reservation booking from a customer. We need to import the booking model, and the booking serializer. At the bottom of the views file we can create the new model view set, using Django REST frameworks built in API view. And the query set will be all booking objects. Serializer class will be set to the booking serializer. And then the permission classes will be set to the base permission. And that's so we don't have to check for a lot of tokens in other permissions. In the serializer's file we're going to be creating the booking serializer. We need to import the booking model. And then create the serialzier itself. It's a model serializer. We set the class meta with the booking model, and we will serialize all fields. Then in the URL configuration, we need to register the bookings path as a new route in the Django REST framework default…

Contents