February 2018
Intermediate to advanced
456 pages
9h 56m
English
Now, it is time to start adding the views! Open the views.py file in the main app directory, and let's add some import statements:
from django.http import HttpResponsefrom django.shortcuts import get_object_or_404from rest_framework import generics, statusfrom rest_framework.response import Responsefrom .models import Orderfrom .status import Statusfrom .view_helper import OrderListAPIBaseViewfrom .view_helper import set_status_handlerfrom .serializers import OrderSerializer
First, we will import the HttpReponse from the django.http module and get_object_or_404 from the django.shortcuts module. The latter is just a helper function that will get an object, and in case it cannot find it, it will return a response with the status ...