diff --git a/mood/templatetags/mood_stats.py b/mood/templatetags/mood_stats.py index 969e7d0..e974d2d 100644 --- a/mood/templatetags/mood_stats.py +++ b/mood/templatetags/mood_stats.py @@ -35,6 +35,9 @@ def current_streak(context): @register.simple_tag(takes_context=True) def closest_mood(context, value): + if not value: + return None + mood_list = context["user"].mood_set.all() found = None @@ -86,6 +89,9 @@ def most_common_activity(context, start, end=None): for activity in status.statusactivity_set.all(): activities.append(activity.activity) + if not activities: + return None + most_common = Counter(activities).most_common(1)[0] return most_common[0], most_common[1]