October 2016
Intermediate to advanced
418 pages
9h 52m
English
We want to be able to list all the users and retrieve the details for a single user. We will create subclasses of the two following generic class views declared in rest_framework.generics:
ListAPIView: Implements the get method that retrieves a listing of a querysetRetrieveAPIView: Implements the get method to retrieve a model instanceGo to the gamesapi/games folder and open the views.py file. Add the following code after the last line that declares the imports, before the declaration of the GameCategoryList class. The code file for the sample is included in the restful_python_chapter_03_04 folder:
from django.contrib.auth.models import User from games.serializers import UserSerializer from rest_framework ...