From a1505bed4443823ad6de46b3b287ff1b2281fcf4 Mon Sep 17 00:00:00 2001 From: Kumi Date: Fri, 1 Jan 2021 21:46:38 +0100 Subject: [PATCH] Filter out status entries that don't have a mood associated from average_mood --- mood/templatetags/mood_stats.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mood/templatetags/mood_stats.py b/mood/templatetags/mood_stats.py index 120b49b..7d3434d 100644 --- a/mood/templatetags/mood_stats.py +++ b/mood/templatetags/mood_stats.py @@ -51,7 +51,8 @@ def average_mood(context, start, end=None): moods = list() for status in status_list: - moods.append(status.mood.value) + if status.mood: + moods.append(status.mood.value) try: average = sum(moods) / len(moods)