February 2018
Intermediate to advanced
456 pages
9h 56m
English
Before we create the views, we are going to create some helper classes and functions that will make the code in the view simpler and clean. Go ahead and create a file called view_helper.py in the main app directory, and as usual, let's start by including the import statements:
from rest_framework import generics, statusfrom rest_framework.response import Responsefrom django.http import HttpResponsefrom .exceptions import InvalidArgumentErrorfrom .exceptions import OrderAlreadyCancelledErrorfrom .exceptions import OrderAlreadyCompletedErrorfrom .serializers import OrderSerializer
Here, we import some things from the Django REST Framework, the main one being the generic, which contains definitions for the generic view classes ...
Read now
Unlock full access