From the course: Building Angular 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
- [Instructor] We already implemented a filter on the Django side for checking permissions of whether or not a user can access or write to a particular package. Now, we want an additional filter. Going to add that after the previous filter. Going to call it TourLengthFilterBackend. It's also a subclass of BaseFilterBackend. And, again, we override the filter_queryset method. And we are going to extract the tour length value from the query params. And if it is set, we're going to return the queryset.filtered by the tour length. Otherwise, we just return the query set as it was. And then we add the FilterBackend here to the PackageViewSet FilterBackends list. And now, we can run our dev server. We can test this out with a curl command. First, we need to log in with our prefilled-in log-in information. Going to post to the oauth token endpoint. So we now have an access token that we can use to make further requests.…
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)
Checking permissions with Django3m 20s
-
(Locked)
Deleting an item using Angular and Django2m 14s
-
(Locked)
Partially updating an item using Angular4m 9s
-
(Locked)
Pagination with Django52s
-
(Locked)
Pagination with Angular3m 29s
-
(Locked)
Filtering with Django2m 38s
-
(Locked)
Filtering with Angular1m 36s
-
(Locked)
Animations in Angular7m 23s
-
(Locked)
-
-
-