0

After installing Django Debug Toolbar and adding all setting, I'm getting 404 error. I did command collectstatic, but that did not help. Here is my files:

settings.py

    BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    ....
    INSTALLED_APPS = [
    ...
    'debug_toolbar',
    ...
    ]
    MIDDLEWARE = [
    ...
    'whitenoise.middleware.WhiteNoiseMiddleware',
    'debug_toolbar.middleware.DebugToolbarMiddleware',
    ]
    ...
    STATIC_URL = '/static/'
    STATIC_ROOT = os.path.join(BASE_DIR, 'static')
    STATICFILES_DIRS = [
        os.path.join(BASE_DIR, 'spare_part/static')
    ]
    MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
    MEDIA_URL = '/media/'

    STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
    INTERNAL_IPS = ["127.0.0.1", ]

urls.py

    urlpatterns = [
    path('admin/', admin.site.urls),
    path('', include('mileage.urls')),
    ]

    if settings.DEBUG:
        import debug_toolbar

        urlpatterns = [
            path('__debug__/', include(debug_toolbar.urls)),
        ]
        urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
        urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

What to do?

error

Vitalii Mytenko
  • 544
  • 5
  • 20

2 Answers2

0

Just found the solution:

in urls.py might to be "urlpatterns +="

    urlpatterns += [
        path('__debug__/', include(debug_toolbar.urls)),
    ]
Vitalii Mytenko
  • 544
  • 5
  • 20
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Dec 01 '21 at 23:06
0

change url.py to :

urlpatterns = [
path('admin/', admin.site.urls),
path('', include('mileage.urls')),
]

if settings.DEBUG:
    import debug_toolbar

    urlpatterns += [
        path('__debug__/', include(debug_toolbar.urls)),
    ]
    urlpatterns += static(settings.MEDIA_URL,
                          document_root=settings.MEDIA_ROOT)
    urlpatterns += static(settings.STATIC_URL, 
    document_root=settings.STATIC_ROOT
sNezamHa
  • 144
  • 6