0PricingLogin
Flask Academy · Lesson

Define a Schema for a Model

Declare fields that map to your model.

What a Schema Is

A Schema is a Python class that lists the fields your data should have. It mirrors a model but lives separately, just for input and output.

Subclass Schema

Every schema inherits from Marshmallow's base Schema class. Naming it after your model, like UserSchema, keeps the intent obvious at a glance.

class UserSchema(Schema):
    pass

All lessons in this course

  1. Why Hand-Built JSON Falls Apart
  2. Define a Schema for a Model
  3. Dump Objects to JSON
  4. Load and Validate Input Payloads
← Back to Flask Academy