From 4443350b3ab60f7f30bc6abfbc8b3c6bb83899f7 Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Sat, 20 Mar 2021 11:17:11 +0100 Subject: [PATCH] Display only published articles in related --- articles/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/articles/models.py b/articles/models.py index 82c5d8b..d662e0a 100644 --- a/articles/models.py +++ b/articles/models.py @@ -132,7 +132,7 @@ class Article(models.Model): def get_related_articles(self): related_articles = set() for tag in self.tags.all(): - related_articles.update(tag.articles.all()) + related_articles.update(tag.articles.filter(status=Article.PUBLISHED)) sample_size = min([len(related_articles), 3]) return random.sample(related_articles, sample_size)