WARNING Not Found: /favicon.ico

Most browsers look for the existence of an file called favicon.ico at the root path of your website domain, this controls the icon for the website you can see in your bookmarks folder or the address bar of your browser.

If you don't have one, then it's valid that it would return a Not Found error.


Almost all Browsers usually look for the existence of a file called favicon.ico at the root path of the website domain, this controls the icon for the website that we can see in the tabs, bookmarks folder or the address bar of the browser.

When the browser searches for favicon.ico and does not find the same, then it is valid that it would return a Not Found error.

django.contrib.staticfiles.storage provides staticfiles_storage, which is an instance of your project’s configured static file storage. Storages have a URL method that “[r]eturns an absolute URL where the file’s contents can be accessed directly by a Web browser.”, which is exactly what the {% static %} tag uses.

So {% static 'favicon.ico' %} in a template is essentially equivalent to staticfiles_storage.url('favicon.ico') in Python. We can add <link rel="icon" href="{% static 'base/icons/favicon.ico' %}"> under <head> tag to the base.html of django.

When we get such error in other domains with error code 404, the link for favicon can be added under <head> section we can add <link> as follows:

<link rel="icon" href="static/projectname/favicon.ico">

or

<link rel="shortcut icon" type="image/x-icon" href="base/icons/favicon.png"/>

Do not forget to add the required location of the icon file favicon.ico, the issue will be resolved.

The favicon.ico could be the logo of the company or anything the website is based upon.


When you deploy to something like Apache, you will have to alias your favicon in a config file. However, while running Django in development mode, the following works

urls.py:

from django.views.generic import RedirectView
from django.conf.urls import url

url_patterns=[
    ...

    url(r'^favicon\.ico$',RedirectView.as_view(url='/static/images/favicon.ico')),
]

Tags:

Python

Django