We took advantage of the pagination features available in Django REST Framework to specify how we wanted large results sets to be split into individual pages of data. However, we have always been working with the entire queryset as the result set. Django REST Framework makes it easy to customize filtering, searching, and sorting capabilities to the views we have already coded.
First, we will install the django-filter
package in our virtual environment. This way, we will be able to use field filtering features that we can easily customize in Django REST Framework. Make sure that you quit the Django's development server. Remember that you just need to press
Ctrl
+
C
in the terminal or Command Prompt window in which it is running. Then, we just need to run the following command to install the django-filter
package:
pip install django-filter
The last lines for the output will indicate that the django-filter
package has been successfully...