Skip to content

Instantly share code, notes, and snippets.

@iepathos
Last active October 4, 2022 17:06
Show Gist options
  • Save iepathos/5350503 to your computer and use it in GitHub Desktop.
Save iepathos/5350503 to your computer and use it in GitHub Desktop.
Fix for Google Chrome favicon loading in Django. You may have noticed that Chrome has issues loading the appropriate favicon on Django if you have it in a different path other than just '/favicon.ico'. Firefox follows the template icon links no problem, but Chrome needs a little more help. I fixed this issue by adding this quick line to the urls…
#urls.py
from django.conf import settings
urlpatterns = patterns('',
url(r'^favicon.ico/$', lambda x: HttpResponseRedirect(settings.STATIC_URL+'ico/favicon.ico')), #google chrome favicon fix
)
# base.html
<link rel="shortcut icon" href="{{ STATIC_URL }}ico/favicon.ico">
@LLigare
Copy link

LLigare commented Jan 24, 2021

on django 3.1.5, it works, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment