Reputation: 9917
My Django-Debug-Toolbar results in a Http404 as soon as I click on a Panel like "Requests". I checked my config multiple times but can't find whats wrong.
Versions:
settings.py
# DEBUG TOOLBAR
if DEBUG:
def custom_show_toolbar(request):
""" Only show the debug toolbar to users with the superuser flag. """
#return request.user.is_superuser
if request.is_ajax():
return False
return True
MIDDLEWARE += (
'debug_toolbar.middleware.DebugToolbarMiddleware',
)
INSTALLED_APPS += (
'debug_toolbar',
)
INTERNAL_IPS = ('127.0.0.1', )
DEBUG_TOOLBAR_CONFIG = {
'INTERCEPT_REDIRECTS': False,
'SHOW_TOOLBAR_CALLBACK': 'core.settings.custom_show_toolbar',
'HIDE_DJANGO_SQL': True,
'TAG': 'body',
'SHOW_TEMPLATE_CONTEXT': True,
'ENABLE_STACKTRACES': True,
}
urls.py
urlpatterns = [
url(r'^$', core_views.home, name='home'),
#url(r'^login/$', auth_views.login, name='login'),
#url(r'^logout/$', auth_views.logout, name='logout'),
#url(r'^oauth/', include('social_django.urls', namespace='social')),
url(r'^admin/', admin.site.urls),
]
if settings.DEBUG:
import debug_toolbar
urlpatterns = [
url(r'^__debug__/', include(debug_toolbar.urls)),
] + urlpatterns
Screenshot
Upvotes: 2
Views: 2007
Reputation: 308769
The problem is your custom_show_toolbar
method. You are explicitly disabling the toolbar for ajax requests. Since the debug toolbar loads the panel using ajax requests, you get a 404.
def custom_show_toolbar(request):
...
if request.is_ajax():
return False
return True
Upvotes: 8