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.
Filtering with Django
- [Male Speaker] Now we want to be able to narrow down the user search for the perfect tour package. We're going to do this by using the base filter, which we import from REST framework. And we also use the search filter. We're going to filter tour packages by their price. So, we create a new package price filter backend. And we define the queryset filter. And the current filters are empty. And we are going to check the query parameters of the incoming request, "searching for price min," and the default will be "none." And if the minimum price is set, we're going to add that filter. The price has to be greater than or equal to the minimum price. We're going to do the same for the maximum price. Difference is, that the price has to be less than or equal to the maximum price. After we've set up these filters, we can return the queryset filtered by those filters. Now, in the Public Package View set, we have to set up…
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
-
-
-
-
Creating a ViewSet with Django1m 2s
-
(Locked)
Displaying a list of items with React2m 47s
-
Deleting an item using React and Django1m 49s
-
(Locked)
Partially updating an item using React1m 50s
-
(Locked)
Pagination with Django38s
-
(Locked)
Pagination with React3m 31s
-
(Locked)
Filtering with Django1m 56s
-
(Locked)
Filtering with React4m 44s
-
-
-
-
-