[Answered ]-Get Latest Article in Two Combined Django Queryset That's Converted to a List

2👍

first Article:

next(obj for obj in all_articles if isinstance(obj, Article))

last Article

next(obj for obj in all_articles[::-1] if isinstance(obj, Article))

first SharedArticle:

next(obj for obj in all_articles if isinstance(obj, SharedArticle))

last SharedArticle

next(obj for obj in all_articles[::-1] if isinstance(obj, SharedArticle))
👤sax

Leave a comment