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
python sqlalchemy


source to share


No one has answered this question yet

Check out similar questions:

9540
What does the yield keyword do?
5504
Does Python have a ternary conditional operator?
5433
What if __name__ == "__main__": do?
5116
How can I check if a file exists without exceptions?
4268
How to combine two dictionaries in one expression?
3790
How can I safely create a subdirectory?
3602
Does Python have a substring method "contains"?
3474
How to list all files in a directory?
3428
How to sort a dictionary by value?
3235
How to check if a list is empty?



All Articles
Loading...
X
Show
Funny
Dev
Pics