I have the following code:
markers = db.relationship("Marker", back_populates="track")
@hybrid_property
def first_marker(self):
if (len(self.markers) > 0) is True:
return self.markers[0]
return None
and using marshmallow to serialize it. But when I run the app, it raises an error:
TypeError: object of type 'InstrumentedAttribute' has no len()
What I want is this hybrid property to return the first element of the markers list. It looks like when I start the app, marshmallow is calling this function with self.markers as the "Relationship" object, but why? How could I fix this?
Thank you for your help!