Search code examples
djangonginxfavicongunicorn

Browser won't show favicon.ico but can browse to it - using Django, nginx gunicorn


This should be easy, but I can't solve it.

I have a favicon.ico at http://myserver.local/favicon.com. I can toss that URL in the browser and it shows the graphic on the page, but not in the menu bar. I'm a bit of a hack, developing only for personal use, so bear with me.

my index.html view includes this in :

<link rel="shortcut icon" href="http://myserver.local/favicon.ico" type="image/x-icon"/>
<link rel="icon" href="http://myserver.local/favicon.ico" type="image/x-icon"/>

Any my nginx myserver.conf file currently looks like this (I've seen a number of ways to do it):

location = /favicon.ico {
    rewrite (.*) /static/favicon.ico;
}

I've tried a few different variations of the heading and nginx config file, but don't see any errors in the logs. Firefox and Safari have both failed to pick up the .ico file.

my configuration is largely based on this excellent tutorial.


Solution

  • You should not have to touch your nginx settings for this.

    Make sure you read up on how static assets work in Django and check out this answer that answers your question: How can I get a favicon to show up in my django app?