Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Ensure the debug toolbar is installed
NyanKiyoshi334bc8f60ba8
diff --git a/saleor/settings.py b/saleor/settings.pyindex becf9e452c..adf47a86d7 100644--- a/saleor/settings.py+++ b/saleor/settings.py@@ -1,5 +1,6 @@import astimport os.path+import warningsimport dj_database_urlimport dj_email_url@@ -269,8 +270,19 @@ INSTALLED_APPS = [ENABLE_DEBUG_TOOLBAR = get_bool_from_env("ENABLE_DEBUG_TOOLBAR", False)if ENABLE_DEBUG_TOOLBAR:- MIDDLEWARE.append("debug_toolbar.middleware.DebugToolbarMiddleware")- INSTALLED_APPS.append("debug_toolbar")+ # Ensure the debug toolbar is actually installed before adding it+ try:+ __import__("debug_toolbar")+ except ImportError as exc:+ msg = (+ f"{exc} -- Install the missing dependencies by "+ f"running `pip install -r requirements_dev.txt`"+ )+ warnings.warn(msg)+ else:+ MIDDLEWARE.append("debug_toolbar.middleware.DebugToolbarMiddleware")+ INSTALLED_APPS.append("debug_toolbar")+DEBUG_TOOLBAR_PANELS = [# adds a request history to the debug toolbar"ddt_request_history.panels.request_history.RequestHistoryPanel",diff --git a/saleor/urls.py b/saleor/urls.pyindex d0a8ff88b5..a01bbe1921 100644--- a/saleor/urls.py+++ b/saleor/urls.py@@ -50,12 +50,17 @@ translatable_urlpatterns = [urlpatterns = non_translatable_urlpatterns + i18n_patterns(*translatable_urlpatterns)if settings.DEBUG:- import debug_toolbar+ try:+ import debug_toolbar+ except ImportError:+ """The debug toolbar was not installed. Ignore the error.+ settings.py should already have warned the user about it."""+ else:+ urlpatterns += [url(r"^__debug__/", include(debug_toolbar.urls))]urlpatterns += [- url(r"^__debug__/", include(debug_toolbar.urls)),# static files (images, css, javascript, etc.)- url(r"^static/(?P<path>.*)$", serve),+ url(r"^static/(?P<path>.*)$", serve)] + static("/media/", document_root=settings.MEDIA_ROOT)if settings.ENABLE_SILK: