Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Enable Django Debug Toolbar on non-production enviroments by default

Pacu2b25a1b40d529
diff --git a/docs/gettingstarted/dev-tools.rst b/docs/gettingstarted/dev-tools.rst
index 62642e48c8..f8682129a7 100644
--- a/docs/gettingstarted/dev-tools.rst
+++ b/docs/gettingstarted/dev-tools.rst
@@ -11,7 +11,7 @@ You can control them with environmental variables:
Controls `django-silk <https://github.com/jazzband/django-silk>`. Defaults to ``False``
-Enabling Debug Tool (example)
+Enabling Silk
-----------------------------
#. Set environment variable.
@@ -21,7 +21,7 @@ Enabling Debug Tool (example)
#. Install packages from requirements_dev.txt:
- .. code-block:: bash
+ .. code-block:: console
$ python -m pip install -r requirements_dev.txt
diff --git a/requirements.in b/requirements.in
index 6891caceeb..0e39920d37 100644
--- a/requirements.in
+++ b/requirements.in
@@ -51,3 +51,4 @@ text-unidecode
uwsgi>=2.0.0 ; platform_system != "Windows"
celery[redis]
weasyprint>=0.42.2
+django-debug-toolbar
diff --git a/requirements.txt b/requirements.txt
index 775de23ffd..81da045efe 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -29,6 +29,7 @@ django-bootstrap4==0.0.5
django-cache-url==2.0.0
django-celery-results==1.0.1
django-countries==5.2
+django-debug-toolbar==1.9.1
django-elasticsearch-dsl==0.4.4
django-environ==0.4.4 # via django-graphql-jwt
django-filter==1.1
@@ -99,6 +100,7 @@ singledispatch==3.4.0.3 # via graphene-django
six==1.11.0 # via bleach, cryptography, django-environ, django-templated-email, elasticsearch-dsl, faker, freezegun, graphene, graphene-django, graphql-core, graphql-relay, html5lib, promise, purl, pytest, python-dateutil, singledispatch, social-auth-app-django, social-auth-core, vcrpy
social-auth-app-django==2.1.0
social-auth-core==1.6.0 # via social-auth-app-django
+sqlparse==0.2.4 # via django-debug-toolbar
stripe==1.77.1 # via django-payments
suds-jurko==0.6 # via django-payments
text-unidecode==1.1
diff --git a/saleor/settings.py b/saleor/settings.py
index a0947e27d4..bc0bb0a16d 100644
--- a/saleor/settings.py
+++ b/saleor/settings.py
@@ -213,9 +213,7 @@ INSTALLED_APPS = [
'impersonate',
'phonenumber_field']
-ENABLE_DEBUG_TOOLBAR = ast.literal_eval(
- os.environ.get('ENABLE_DEBUG_TOOLBAR', 'False'))
-if ENABLE_DEBUG_TOOLBAR:
+if DEBUG:
MIDDLEWARE.append(
'debug_toolbar.middleware.DebugToolbarMiddleware')
INSTALLED_APPS.append('debug_toolbar')
diff --git a/saleor/urls.py b/saleor/urls.py
index f1b694f635..f755078fb2 100644
--- a/saleor/urls.py
+++ b/saleor/urls.py
@@ -53,16 +53,13 @@ urlpatterns = non_translatable_urlpatterns + i18n_patterns(
*translatable_urlpatterns)
if settings.DEBUG:
- # static files (images, css, javascript, etc.)
+ import debug_toolbar
urlpatterns += [
+ url(r'^__debug__/', include(debug_toolbar.urls)),
+ # static files (images, css, javascript, etc.)
url(r'^static/(?P<path>.*)$', serve)] + static(
settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
-if settings.ENABLE_DEBUG_TOOLBAR:
- import debug_toolbar
- urlpatterns += [
- url(r'^__debug__/', include(debug_toolbar.urls))]
-
if settings.ENABLE_SILK:
urlpatterns += [
url(r'^silk/', include('silk.urls', namespace='silk'))]