Created
June 3, 2019 04:16
-
-
Save Joel-hanson/6cbbf56b3de6afa75f6b2c1f45f6a5ee to your computer and use it in GitHub Desktop.
We will be using the ModelViewSet and ModelSerializer to make the API for our Book model.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from rest_framework.viewsets import ModelViewSet | |
from rest_framework.authentication import SessionAuthentication | |
from .serializers import BookModelSerializer | |
from .models import Book | |
# Create your views here. | |
class BookModelViewSet(ModelViewSet): | |
""" | |
A simple ViewSet for viewing and editing books. | |
""" | |
queryset = Book.objects.all() | |
serializer_class = BookModelSerializer | |
authentication_classes = [SessionAuthentication] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment