Configuring filtering, searching, and ordering for views

Go to the gamesapi/games folder and open the views.py file. Add the following code after the last line that declares the imports but before the declaration of the UserList class. The code file for the sample is included in the restful_python_chapter_04_02 folder:

from rest_framework import filters 
from django_filters import NumberFilter, DateTimeFilter, AllValuesFilter 

Add the following highlighted lines to the GameCategoryList class declared in the views.py file. The code file for the sample is included in the restful_python_chapter_04_02 folder:

class GameCategoryList(generics.ListCreateAPIView): queryset = GameCategory.objects.all() serializer_class = GameCategorySerializer name = 'gamecategory-list' ...

Get Building RESTful Python Web Services now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.