October 2016
Intermediate to advanced
418 pages
9h 52m
English
Now, we will create the models that we can use to represent and persist the message categories, messages, and their relationships. Open the api/models.py file and replace its contents with the following code. The lines that declare fields related to other models are highlighted in the code listing. In case you created a new virtual environment, create a new models.py file within the api folder. The code file for the sample is included in the restful_python_chapter_06_01 folder:
from marshmallow import Schema, fields, pre_load from marshmallow import validate from flask_sqlalchemy import SQLAlchemy from flask_marshmallow import Marshmallow db = SQLAlchemy() ma = Marshmallow() class AddUpdateDelete(): def ...