# 05 - Scheming Schemas

## Marshmallow and Schemas

Marshmallow is a Python library which enables us to easily sanitize and validate content according to a schema. Schemas are useful when we want to sift through user provided data in a group rather than dealing with each item individually. Schemas define how we will dump data and which fields/attributes will get through.

To achieve this, we need two items from marshmallow, the `Schema` object and `fields`. Add the following import statement to both model files, and add the trailing schema classes to their respective model files

`from marshmallow import Schema, fields`

![UserSchema definition for UserModel](https://2289778881-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LbPPMDdogM4POiHwAId%2F-LbPPg9qhO4XswC1MXCg%2F-LbPPhJTJmpBRYCpeY3Y%2Fuser_schema.jpg?generation=1554147632518556\&alt=media)

![BlogPostSchema definition](https://2289778881-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LbPPMDdogM4POiHwAId%2F-LbPPg9qhO4XswC1MXCg%2F-LbPPhJVkz8plbC2wtY-%2Fblog_post_schema.png?generation=1554147632989120\&alt=media)

Building this schema will also fix an error from the previous module as at the time we never had the `BlogPostSchema`
