Serialize two nested schema with marshmallow
<p>I am fairly new to python. I have two SQLAlchemy models as follows:</p>

<pre><code>class listing(db.Model):
 id = db.Integer(primary_key=True)
 title = db.String()
 location_id = db.Column(db.Integer, db.ForeignKey('location.id'))
 location = db.relationship('Location', lazy='joined')

class location(db.Model):
 id = db.Integer(primary_key=True)
 title = db.String()
</code></pre>

<p>I have two Marshmallow schema classes for them:</p>

<pre><code>class ListingSchema(Schema):
 id = fields.Int()
 title = fields.Str()
 location_id = fields.Int()

class LocationSchema(Schema):
 id = fields.Int()
 title = fields.Str()
</code></pre>

<p>I have created a nested schema class like:</p>

<pre><code>class NestedSchema(Schema):
 listing = fields.Nested(ListingSchema)
 location fields.Nested(LocationSchema)
</code></pre>

<p>I am doing the join query like :</p>

<pre><code>listing,location = db.session.query(Listing,Location)\
                            .join(Location, and_(Listing.location_id == Location.id))\
                            .filter(Listing.id == listing_id).first()
</code></pre>

<p>data gets load in the objects i have checked. How can parse this schema?
I have tried</p>

<pre><code>result,errors = nested_listing_Schema(listing,location)
</code></pre>

<p>This gives error: "Listing object is not iteratable."</p>