From e8978cc06568d76e73219ef4dd1a0cbfd20beb9d Mon Sep 17 00:00:00 2001 From: Skia Date: Fri, 1 Oct 2021 14:08:57 +0200 Subject: [PATCH] sith/toolbar_debug: don't fail when there is no template --- sith/toolbar_debug.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sith/toolbar_debug.py b/sith/toolbar_debug.py index 03b531d5..139aec36 100644 --- a/sith/toolbar_debug.py +++ b/sith/toolbar_debug.py @@ -1,7 +1,8 @@ # -*- coding:utf-8 -* # -# Copyright 2016,2017 +# Copyright 2016,2017,2021 # - Sli +# - Skia # # Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM, # http://ae.utbm.fr. @@ -27,7 +28,10 @@ from debug_toolbar.panels.templates import TemplatesPanel as BaseTemplatesPanel class TemplatesPanel(BaseTemplatesPanel): def generate_stats(self, *args): - template = self.templates[0]["template"] - if not hasattr(template, "engine") and hasattr(template, "backend"): - template.engine = template.backend + try: + template = self.templates[0]["template"] + if not hasattr(template, "engine") and hasattr(template, "backend"): + template.engine = template.backend + except IndexError: # No template + pass return super().generate_stats(*args)