djangodjango-debug-toolbar

Django debug toolbar and include in urls.py (supposedly)


Django 3.0.6

Main urls.py

urlpatterns = [
    path('', HomeView.as_view(), name='home'),
    path('{}'.format("admin/" if DEBUG else "dhjfsljdasdhje32/"), admin.site.urls), # Change admin url for security reasons.
    path('post/', include('post.urls')),
]

if DEBUG:
    import debug_toolbar
    urlpatterns += [
        path('__debug__/', include(debug_toolbar.urls)),
    ]
    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

post.urls.py

urlpatterns = [
    path('<int:pk>/', PostDetailView.as_view(), name='detail'),
]

Problem

When I try these addresses: http://localhost:8000/, http://localhost:8000/admin/, Django Debut Toolbar is showing.

But when I try http://localhost:8000/post/1/, the debug toolbar is not showing.

Supposedly, it has something to do with include. But I'm not sure.

Could you hep me here?


Solution

  • Your DetailView template contains closing tag </body>? I had similar problem because one of my pages didn't has this tag.