Using django_debug_toolbar alongside drf_spectacular

158 Views Asked by At

I'm using drf_spectacular as swagger for my django projects since drf_yasg is deprecated. I tried to use django_debug_toolbar alongside drf_spectacular and I followed all of the instructions. The debug_toolbar's icon appears in swagger but when I try to call any api, a 'Not Found' error keeps showing up repeatedly!

swagger

logs

What is the problem? What should I do?

1

There are 1 best solutions below

0
Mehrdad HMT On

I found the solution! The problem was the order of urls!!!

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

urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

Back then, the debug toolbar url was after static urls! I changed the order and it worked! However, I still can't understand why!