From 710149ec21d36d390e024871bc31b2c6a2f60396 Mon Sep 17 00:00:00 2001 From: Peter Pfeufer Date: Wed, 14 Aug 2024 13:22:23 +0200 Subject: [PATCH] [FIX] Check if the CustomCSS object exists --- .../custom_css/templatetags/custom_css.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/allianceauth/custom_css/templatetags/custom_css.py b/allianceauth/custom_css/templatetags/custom_css.py index d3a935a9..3c01602f 100644 --- a/allianceauth/custom_css/templatetags/custom_css.py +++ b/allianceauth/custom_css/templatetags/custom_css.py @@ -33,11 +33,16 @@ def custom_css_static(path: str) -> str: except FileNotFoundError: return "" else: - custom_css_changed = CustomCSS.objects.first().timestamp.timestamp() - custom_css_version = ( - str(custom_css_changed).replace(" ", "").replace(":", "").replace("-", "") - ) # remove spaces, colons, and dashes - static_url = static(path) - versioned_url = static_url + "?v=" + custom_css_version + try: + custom_css = CustomCSS.objects.get(pk=1) + except CustomCSS.DoesNotExist: + return "" + else: + custom_css_changed = custom_css.timestamp.timestamp() + custom_css_version = ( + str(custom_css_changed).replace(" ", "").replace(":", "").replace("-", "") + ) # remove spaces, colons, and dashes + static_url = static(path) + versioned_url = static_url + "?v=" + custom_css_version - return mark_safe(f'') + return mark_safe(f'')