From 5137adf89c030211a098e7fa23fd7b5a948033f1 Mon Sep 17 00:00:00 2001
From: Fredrik Jonsson <frjo@xdeb.org>
Date: Wed, 28 Feb 2024 17:18:27 +0100
Subject: [PATCH] Avoid error when no submission values exist.

---
 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 c9834186dc..896884b663 100644
--- a/hypha/apply/funds/views.py
+++ b/hypha/apply/funds/views.py
@@ -1723,10 +1723,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,