Published 2021-02-12.
Last modified 2021-03-27.
Time to read: 1 minutes.
django
collection.
Django Debug Toolbar
The Django Debug Toolbar is a very useful tool, and is easy to set up. This is a good video on YouTube about installing Django Debug Toolbar.
The Django Debug Toolbar is only needed for development, so it should be installed after
separate settings for dev
have been established.
I put the Django Debug Toolbar settings in settings/dev.py
.
Below is my complete settings/dev.py
for Frobshop;
the only line not associated with Django Debug Toolbar is the one starting with EMAIL_BACKEND
:
from .base import *
DEBUG = True
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
DEBUG_TOOLBAR_CONFIG = { 'JQUERY_URL': '', }
INSTALLED_APPS += [ 'debug_toolbar', ]
INTERNAL_IPS = [ '127.0.0.1', ]
MIDDLEWARE += [ 'debug_toolbar.middleware.DebugToolbarMiddleware', ]
The only other changes required in order for the Django Debug Toolbar to operate are:
-
Add the following to
urls.py
:urls.pyimport debug_toolbar
urlpatterns = [ path('__debug__/', include(debug_toolbar.urls)), ] -
Add the
.dev
qualifier tofrobshop.settings
inmanage.py
:manage.pyos.environ.setdefault('DJANGO_SETTINGS_MODULE', 'frobshop.settings.dev')
Now install Django Debug Toolbar and update requirements.txt
:
(aw) $ python -m pip install django-debug-toolbar
(aw) $ pip freeze > requirements.txt