Taking advantage of generic class-based views
Open the views.py
file in the games_service/games
folder. Replace the code in this file with the following lines. The new code declares the required imports and the class-based views. We will add more classes to this file later. The code file for the sample is included in the restful_python_2_06_01
folder, in the Django01/games-service/games/views.py
file:
from games.models import EsrbRating
from games.models import Game
from games.models import Player
from games.models import PlayerScore
from games.serializers import EsrbRatingSerializer
from games.serializers import GameSerializer
from games.serializers import PlayerSerializer
from games.serializers import PlayerScoreSerializer
from rest_framework import generics
from rest_framework.response import Response
from rest_framework.reverse import reverse
class EsrbRatingList(generics.ListCreateAPIView):
queryset = EsrbRating.objects.all()
serializer_class = EsrbRatingSerializer...