Adding views

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 ...

Get Python Programming Blueprints now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.