Django-debug-toolbar return error while trying to see static files

87 Views Asked by At

I have django-debug-toolbar and everythings works fine except i try to see static files which uses on this page

Pannel shows me how many static files are using on this page but i cant get info about them

I got an error 400 Bad Request and error in terminal:

django.core.exceptions.SuspiciousFileOperation: The joined path (/css/style.css) is located outside of the base path component (/home/kirill_n/PycharmProjects/my_proj/venv/lib/python3.10/site-packages/django/contrib/admin/static)

Bad Request: /__debug__/render_panel/

GET /__debug__/render_panel/?store_id=62e0bb7a200049efa762b6b5d59c118f&panel_id=StaticFilesPanel HTTP/1.1" 400 2

settings.py

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATIC_ROOT_FILES = os.path.join(BASE_DIR, 'static_src')
STATICFILES_DIRS = (
    'static_src',
)

STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    'django.contrib.staticfiles.finders.FileSystemFinder',
)

MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')


ALLOWED_HOSTS = ['*']

INSTALLED_APPS += [

    'debug_toolbar',

]
MIDDLEWARE += [

    'debug_toolbar.middleware.DebugToolbarMiddleware',

]

INTERNAL_IPS = [
    '127.0.0.1',
]


urls.py

if settings.DEBUG:
    import debug_toolbar

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

0

There are 0 best solutions below