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
From the course: Building React and Django Apps
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…
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)
Handling creating models with Django REST framework1m 39s
-
(Locked)
Creating a REST API Service class with React and Axios2m 24s
-
(Locked)
Creating a basic form as a React component2m 22s
-
(Locked)
Creating form fields for basic form2m 6s
-
(Locked)
Connecting a React component to a service2m 26s
-
(Locked)
Validating form data with Django REST framework54s
-
(Locked)
Displaying validation errors with React1m 23s
-
(Locked)
-
-
-