Django Debug Toolbar Loaded but not showing/appearing, Fix it and Bring it Back.
*Are you facing the problem with Django Debug Toolbar showing up?*
I faced too…
Here I will show you how I fixed it….
Install Debug Toolbar…
For virtual env: pip install django-debug-toolbar
For Pipenv: pipenv install django-debug-toolbar
Link: https://pypi.org/project/django-debug-toolbar/
Docs: https://django-debug-toolbar.readthedocs.io/en/latest/
Go to settings.py and add to INSTALLED_APPS
INSTALLED_APPS = [
# …
‘django.contrib.staticfiles’,
# … not for debug mode
‘debug_toolbar’,
]STATIC_URL = ‘/static/’
The Debug Toolbar should have appeared only in Debug mode. So, the rest of the settings will be for DEBUG mode only.
# debug_toolbar moved here.
if DEBUG:
MIDDLEWARE += [
'debug_toolbar.middleware.DebugToolbarMiddleware',
]
INSTALLED_APPS += [
'debug_toolbar',
]
INTERNAL_IPS = ['127.0.0.1', ]
# this is the main reason for not showing up the toolbar
import mimetypes
mimetypes.add_type("application/javascript", ".js", True)
DEBUG_TOOLBAR_CONFIG = {
'INTERCEPT_REDIRECTS': False,
}
Update your {project}/urls.py
file.
from django.conf import settings
from django.urls import path, includeurlpatterns = [
path("admin/", admin.site.urls),
]# add debug toolbar in urlpatterns
if settings.DEBUG:
import debug_toolbar
urlpatterns += [
path('__debug__/', include(debug_toolbar.urls)),
]
The main reason for not showing up the toolbar is because of the javascript mime-types error when you connect the debug_toolbar
If the already added to your application then just add two lines of code in your settings.py file.
mimetypes
mimetypes.add_type("application/javascript", ".js", True)
Now the debug toolbar should be visible in Debug mode.
If you need any help with Full-Stack Development with Django and Shopify, feel free to contact me anytime.
Visit: imtipu.me
Contact if you need any help with Django and Shopify
Skype: me@imtipu.me
Email: me@imtipu.me
Thanks!