From b758b4c9d327698ba1cee0e2709d45b8943a507a Mon Sep 17 00:00:00 2001 From: Julian Perelli Date: Thu, 27 Jun 2024 15:39:27 +0200 Subject: [PATCH] fix filenotfound error --- apps/core/templatetags/pngtowebp.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/apps/core/templatetags/pngtowebp.py b/apps/core/templatetags/pngtowebp.py index 8eeaf5a3..5b721052 100644 --- a/apps/core/templatetags/pngtowebp.py +++ b/apps/core/templatetags/pngtowebp.py @@ -12,7 +12,10 @@ def pngtowebp(path): @register.filter def pngorwebpurl(filefield): - if filefield.storage.exists(pngtowebp(filefield.file.name)): - return pngtowebp(filefield.url) - else: + try: + if filefield.storage.exists(pngtowebp(filefield.file.name)): + return pngtowebp(filefield.url) + else: + return filefield.url + except FileNotFoundError as e: return filefield.url