pythonflaskflask-sqlalchemyflask-marshmallow

Including flask-marshmallow causes failure


I've got flask-marshmallow of 0.13.0 version

I'm able to access SQLAlchemyAutoSchema in the flask app

when i try to run the application, i get the following error

AttributeError: 'Marshmallow' object has no attribute 'SQLAlchemyAutoSchema'

initialisation of flask marshmallow

    from flask_sqlalchemy import SQLAlchemy

    from flask_marshmallow import Marshmallow
        
    db = SQLAlchemy()
    ma = Marshmallow()

I've registered both db and ma with flask app code:

from apis import ma

from apis.models import User


class UserSchema(ma.SQLAlchemyAutoSchema):
    class Meta:
        model = User

Solution

  • flask-marshmallow has a dependency on marshmallow-sqlalchemy for the SQLAlchemySchema classes to be defined.

    Make sure you also install marshmallow-sqlalchemy.