Forums

Images broken only in certain pages (working correctly in others)

Hello everyone, sorry if this is a dumb/frequent question, but I can't seem to wrap my head around it.

I've recently started a python course and I wanted to host the django project we were working on, and while I managed to get it up and going fine, some images are still broken with DEBUG set to false.

For example, both my 'login' and 'register' pages have the same line of code:
<img class="responsive" src="banner.png">

But for some reason, while on the login page the image loads fine, on the register page it's broken. I've checked and both have near identical html and the '{% load static %}' line.

Same thing happens in some of my forms to 'edit products' or 'edit profile', things like the nav bar and footer images are broken, which shouldn't happen since I am using extends/includes from 1 singular html for both of these. The only thing these pages have that are different are the decorators but I can't see how this could affect static files... :/

Thanks in advance for your help.

WebApp: http://birbgrandma.eu.pythonanywhere.com/

See our help page on debugging static files issues: https://help.pythonanywhere.com/pages/DebuggingStaticFiles/

I've read through that page, but I don't have a problem with my static files in general. The thing is, my static files are working but... for some reason in some specific pages the same file, with exact same code, doesn't work.

This is the case of the "banner.png" file that I mentioned in my post, the exact same picture, exact same code, loads on one page but not the other.

Even files that are imported across all pages, like the nav bar's logo, which is included in all html pages via {% include 'accounts/navbar.html' %} works fine in most, but is broken in others, I don't have this issue with DEBUG turned to TRUE.

Since I can't really find my specific issue anywhere, I'll sent a message to email adress on the DebuggingStaticFiles link.

Check the requests in your browser's developer tools. Perhaps that will give you some indication of what the issue might be.

I ended up entering the Django discord server and someone helped me there.

If anyone's is curious, there was a problem with my static url, making pages that used a custom url ID not being able to fetch images even when they were on the basic directory, after using 'collectstatic'.

So, for example, "/catalogue" would fetch images correctly, but "/products/(products id)" would not fetch images correctly.

Thank you for your suggestions though. :)

Thanks for letting us know!