Search code examples
pythondjangofavicon

When I visit django Project WebPage, the log remind me:not found favicon


Why django project receive favicon request?

like this
Not Found: /favicon.ico
[23/Jul/2016 11:37:11] "GET /favicon.ico HTTP/1.1" 404 1941

Where did the request come from?

I find request from my browser.
Can I control it? How to close it?
Thanks everyone that care this question...(Bab English, sorry)


Solution

  • The error message that you are seeing is from Django, letting you know that a request was made for the favicon.ico file, and that it returned a 404 error.

    The request for the favicon icon is usually made by the browser when you first access the site. This is the little icon that you see next to urls, like this: https://i.sstatic.net/MBX7A.jpg

    The error is correctable via many ways, as explained here(basic html): Adding a favicon to a static HTML page

    Since you are using django I would recommend taking a look at this guide as well(django version): http://staticfiles.productiondjango.com/blog/failproof-favicons/

    Basically you need to make the favicon.ico icon available to the requester via HTML code, like this: {% static 'favicon.ico' %}: if within a template and the icon in the static folder

    or this: <link rel='shortcut icon' type='image/x-icon' href='/favicon.ico' />

    Good luck!