Home > Blockchain >  Django doesn't find some static files
Django doesn't find some static files

Time:01-17

I'm working on a project and since some days, one specific image cannot be found anymore. Everytime I reload the page, this line in the console appears:

"GET /staticfiles/my_app/images/Logo.svg HTTP/1.1" 404 5715

I know that the image exists because sometimes it appears for a short moment (until you reload again) and other images in the same folder as the Logo.svg are also loading so I guess that the path is not the problem. The setting for the STATICFILES_DIRS is also correct since other things do work.

STATICFILES_DIRS = ( os.path.join('my_app/static'), )

Did anyone have a problem like this before?

CodePudding user response:

in the main urls.py file make sure that static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) line is included.

Also, if the image is being loaded for a short time it could be a browser cache problem. Try clearing the browser's cache or insert the following on top of HTML template: <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate"/>

  • Related