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.
Validating form data with Django REST framework
From the course: Building React and Django Apps
Validating form data with Django REST framework
- [Instructor] Right now, the validation is simple, whether or not a form is filled out. Let's do something a bit more useful. Let's check for a specific street address format. In the booking serializer, we're going to add a street address error message. In a Django REST framework serializer, you only have to prefix the field name with validate in order to implement custom validation for the field. We can define a regular expression that we want to match, which will be a number followed by a street name and any other suffix and if the street address that's filled out matches, we simply return that value. Otherwise, we raise a validation error.
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)
-
-
-