From f51c8ef87a1b6ab79203eb706291e2b43aeda113 Mon Sep 17 00:00:00 2001 From: Fredrik Jonsson Date: Thu, 29 Feb 2024 14:26:04 +0100 Subject: [PATCH] Avoid error when no submission values exist. (#3786) Fixes #3785 Add a check to see if there are any submission values. --- hypha/apply/funds/views.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/hypha/apply/funds/views.py b/hypha/apply/funds/views.py index 54649a0e39..e5dc76c60d 100644 --- a/hypha/apply/funds/views.py +++ b/hypha/apply/funds/views.py @@ -1724,10 +1724,16 @@ def get_queryset(self): def get_context_data(self, **kwargs): search_term = self.request.GET.get("query") - submission_values = self.object_list.value() - count_values = submission_values.get("value__count") - total_value = intcomma(submission_values.get("value__sum")) - average_value = intcomma(round(submission_values.get("value__avg"))) + + if self.object_list: + submission_values = self.object_list.value() + count_values = submission_values.get("value__count") + total_value = intcomma(submission_values.get("value__sum")) + average_value = intcomma(round(submission_values.get("value__avg"))) + else: + count_values = 0 + total_value = 0 + average_value = 0 return super().get_context_data( search_term=search_term,