How to arrange relationships according to the appropriate model?

Consider the following model definitions:

class Issue(Base):
    id = Column(Integer, primary_key=True)
    timestamp = Column(DateTime)

class Author(Base):
    id = Column(Integer, primary_key=True)

class Article(Base):
    [...]
    issue_id = Column(Integer, ForeignKey('issue.id'))
    issue = relationship('Issue')
    author_id = Column(Integer, ForeignKey('author.id'))
    author = relationship('Author', backref=backref('articles', order_by=<???>))

      

I would like the relation Author.articles

(defined above as the backref of the relation Article.author

) to be ordered by articles' issue.timestamp

.

Is it possible?

BONUS : what if Article

has multiple foreign keys for the model Issue

?

+3


source to share





All Articles