So far, our RESTful API has performed CRUD operations on a simple dictionary that acted as a data repository. Now, we want to create a more complex RESTful API with Flask RESTful to interact with a database model that has to allow us to work with messages that are grouped into message categories. In our previous RESTful API, we used a string attribute to specify the message category for a message. In this case, we want to be able to easily retrieve all the messages that belong to a specific message category, and therefore, we will have a relationship between a message and a message category.
We must be able to perform CRUD operations on different related resources and resource collections. The following list enumerates the resources and the class name that we will create to represent the model:
Message categories (
Category
model)Messages (
Message
model)
The message category (Category
) just requires an integer name, and we need the...