Skip to content

Commit

Permalink
Add setup for the Django Debug Toolbar
Browse files Browse the repository at this point in the history
  • Loading branch information
markkuriekkinen committed May 5, 2023
1 parent dceffec commit 8ab5a0e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
16 changes: 16 additions & 0 deletions jutut/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@


## Base options
DEBUG = False
BASE_DIR = dirname(dirname(abspath(__file__)))
EMAIL_SUBJECT_PREFIX = '[MOOC-Jutut] '
WSGI_APPLICATION = 'jutut.wsgi.application'
Expand Down Expand Up @@ -390,3 +391,18 @@

# Resolve app dependencies, check context processors and so on...
update_settings_fixes(__name__)

# Set up Django Debug Toolbar.
if DEBUG:
INSTALLED_APPS += ('debug_toolbar',)
# Add the debug toolbar middleware to the start of MIDDLEWARE.
MIDDLEWARE.insert(
0,
'debug_toolbar.middleware.DebugToolbarMiddleware',
)
# The following variables may have been defined in local_settings.py or environment variables.
try:
if '127.0.0.1' not in INTERNAL_IPS:
INTERNAL_IPS.append('127.0.0.1')
except NameError:
INTERNAL_IPS = ['127.0.0.1']
11 changes: 10 additions & 1 deletion jutut/urls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from django.conf.urls import include, url
from django.conf.urls import url
from django.urls import include, path
from django.conf import settings
from django.contrib import admin

import core.urls
Expand All @@ -15,3 +17,10 @@
url(r'^admin/', admin.site.urls),
url(r'^accounts/', include(accounts.urls)),
]

if settings.DEBUG:
import debug_toolbar
urlpatterns.insert(
0,
path('__debug__/', include(debug_toolbar.urls)),
)

0 comments on commit 8ab5a0e

Please sign in to comment.