title: AttributeError: 'dict' object has no attribute '_sa_instance_state'
body: <p>Am creating a <code>flask_restful</code> API with <code>sqlalchemy</code> and <code>marshmallow</code>.
  Here is my model </p>
  
  <pre><code>class User(db.Model):
      """Basic user model
      """
  
      id = db.Column(db.Integer, primary_key=True)
      username = db.Column(db.String(80), unique=True, nullable=False)
      email = db.Column(db.String(80), unique=True, nullable=False)
      password = db.Column(db.String(255), nullable=False)
      active = db.Column(db.Boolean, default=True)
      is_admin = db.Column(db.Boolean, default=False)
      profile = db.relationship("Profile", back_populates="user", uselist=False)
  
  class Profile(db.Model):
      """Profile model
      """
  
      id = db.Column(db.Integer, primary_key=True)
      fullname = db.Column(db.String(80), unique=False, nullable=True)
      img_url = db.Column(db.String(255), unique=False, nullable=True)
      telephone = db.Column(db.String(20), unique=False, nullable=True)
      user_id = db.Column(
          db.Integer,
          db.ForeignKey('user.id'),
          nullable=False)
      user = db.relationship("User", back_populates="profile")
  </code></pre>
  
  <p>and here user resource for updating <code>PUT</code> request</p>
  
  <pre><code>class UserResource(Resource):
  
      def put(self, user_id):
          schema = UserSchema()
          user = User.query.get_or_404(user_id)
  
          data = {
              'username': 'updated',
              "password": 'HRcdxRu45',
              'email': 'ms@gt.vom',
              'profile': {
                  'telephone': '+2507800112233',
                  'fullname': 'Mic Lolo',
                  'img_url': 'images/img.jpg'
              }
          }
  
          user = schema.load(data, instance=user)
  
          return {"message": "user updated", "data": schema.dump(user)}
  
  </code></pre>
  
  <p>Here is my schema</p>
  
  <pre><code>class ProfileSchema(ma.Schema):
      id = ma.Int(dump_only=True)
      fullname = ma.Str(validate=Length(min=3, max=80, error='empty fullname'))
      img_url = ma.Str(validate=Length(min=3, max=80, error='empty image url'))
      telephone = ma.Str(validate=Regexp(regex=r"\+[0-9]{7,13}", error="Invalid phone number"))
  
      class Meta:
          model = Profile
          sqla_session = db.session
  
  
  class UserSchema(ma.ModelSchema):
      id = ma.Int(dump_only=True)
      password = ma.Str(load_only=True,
                        validate=Length(min=8, max=255, error='empty password'))
      username = ma.Str(validate=Length(min=3, max=80, error='empty username'))
      is_admin = ma.Bool()
      email = ma.Email()
      profile = ma.Nested(ProfileSchema)
  
      class Meta:
          model = User
          sqla_session = db.session
  
  </code></pre>
  
  <p>Am geting
  <a href="https://i.stack.imgur.com/g4Nab.png" rel="noreferrer">AttributeError: 'dict' object has no attribute '_sa_instance_state'</a></p>
  
  <p>When I remove the nested profile schema from <code>UserSchema</code> there is no error but <code>user.profile</code> will not be updated. Also when I remove the <code>instance=user</code> parameter in <code>schema.load(data, instance=user)</code> there is no error and I will get a fine user instance with posted data the problem here again is that there will not be any link between that user instance and the one existing in the database, I will have to find manually which user's field to update.</p>