LBJ33
LBJ33

Reputation: 449

Favicon not loading in Django

I can't seem to get my favicon to load at all, I have the image in my static folder, all other images load fine on both local and production environments, and I can load the favicon as an image no problem. It just doesn't load as the actual favicon. I have the code to load favicon in the head tag (and all other static files that are loaded there are working, such as style sheets and meta tags). I have {% load static %} at the top of the page as well.

Here is my code in the tag which attempts to set the favicon:

    <link rel="icon" type="image/png" href="{% static 'stockdeepdive/images/favicon.ico' %}">
    <link rel="icon" type="image/png" sizes="192x192"  href="{% static 'stockdeepdive/images/android-icon-192x192.png' %}">
    <link rel="icon" type="image/png" sizes="32x32" href="{% static 'stockdeepdive/images/favicon-32x32.png' %}">
    <link rel="icon" type="image/png" sizes="96x96" href="{% static 'stockdeepdive/images/favicon-96x96.png' %}">
    <link rel="icon" type="image/png" sizes="16x16" href="{% static 'stockdeepdive/images/favicon-16x16.png' %}">

The images are all located within static folder, then stockdeepdive folder, then finally images folder. All other images are working good. Im not getting any errors in console, but I'm also not seeing any "GET" request for the favicons.

Any help greatly appreciated, I've spent hours trying to figure this out.

Upvotes: 1

Views: 1457

Answers (3)

Jaime38130
Jaime38130

Reputation: 165

I had the same problem, in my case only changing the name solved. Cleaning the cache did not work. After I changed the name of the image worked! I don't know why.

Upvotes: 1

soulshake
soulshake

Reputation: 969

I had the same problem. In my case, just before the <link rel="icon" ...> lines, I had a <div>, which is not allowed inside <head> according to the HTML spec. After I removed the <div> tags, the favicon started working.

Upvotes: 0

LBJ33
LBJ33

Reputation: 449

Finally figured this out, I'll leave up in case someone else has the same problem.

I fixed it by taking out the type tag. Not sure why it was causing an issue.

Upvotes: 3

Related Questions