Creating the order model serializer
We now have everything we need to start creating out API endpoints. In this section, we are going to create endpoints for every method that we implemented in the Order
manager.
For some of these endpoints, we are going to use the Django REST Framework. The advantage of using the Django REST Framework is that the framework includes a lot of out of the box features. It has different authentication methods, a really robust serialization of objects, and my favorite is that it will give you a web interface where you can browse the API, which also contains a large collection of base classes and mixins when you need to create class-based views.
So, let's dive right into it!
The first thing that we need to do at this point is to create serializer classes for the entities of our model, the Order
, OrderCustomer
, and OrderItem
.
Go ahead and create a file called serializers.py
 in the main app
directory, and let's start by adding a few import statements:
import functools...