From 6028be3d297ec76bd0b584553fb56679a85a43b9 Mon Sep 17 00:00:00 2001 From: David Vogt Date: Fri, 9 Dec 2022 09:32:43 +0100 Subject: [PATCH] fix: do not crash when django-extensions is missing When enabling dev mode, we should not rely on all the dev dependencies being installed. Instead, try to see if `django-extensions` is even installed, and only add it to the `INSTALLED_APPS` list if it is. --- caluma/settings/django.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/caluma/settings/django.py b/caluma/settings/django.py index 1037a3ef1..76c6facc0 100644 --- a/caluma/settings/django.py +++ b/caluma/settings/django.py @@ -33,7 +33,14 @@ ] if DEBUG: - INSTALLED_APPS.append("django_extensions") + try: + __import__("django_extensions") + INSTALLED_APPS.append("django_extensions") + except ImportError: # pragma: no cover + # Nothing bad, just won't have django-extensions + # niceties installed (Most likely Caluma was built) + # without dev dependencies + pass MIDDLEWARE = [ "django.middleware.security.SecurityMiddleware",