rediet yosef
rediet yosef

Reputation: 222

Django Favicon issue

what ever i try to do i can't get the favicon to show up, when i look it up in the view source tab it loads up but won't appear in the tab icon position.

i'm importing it in the html like so:

{% load static %}
<link rel="stylesheet" href="{% static "css/index.css" %}"/>
<link rel="Favicon" type="image/png" href="{% static 'images/icon.png' %}"/>

i set the django staticfile_dirs like so:

STATICFILES_DIRS = [
    os.path.join('static'),
    os.path.join('static/images'),
    ]

Upvotes: 1

Views: 779

Answers (3)

syeda jannat
syeda jannat

Reputation: 26

Try .ico format instead of .png format and rel="shortcut icon" or rel="icon"

Upvotes: 1

willeM_ Van Onsem
willeM_ Van Onsem

Reputation: 477533

The value of the rel="…" attribute should be icon [mdn webdocs], not Favicon:

<link rel="icon" type="image/png" href="{% static 'images/icon.png' %}"/>

Upvotes: 1

Zags
Zags

Reputation: 41328

If your image loads in the browser, you need to have the favicon link be rel="icon" rather than rel="Favicon".

See Do you have to include <link rel="icon" href="favicon.ico" type="image/x-icon" />?

Additionally, you can add a URL route called "favicon.ico" that returns your file.

If your image doesn't load, there is a problem with your static asset serving: https://docs.djangoproject.com/en/dev/howto/static-files/

Upvotes: 0

Related Questions