-
-
Save iepathos/5350503 to your computer and use it in GitHub Desktop.
#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"> |
from django.views.generic.base import RedirectView
url(r'^favicon.ico$', RedirectView.as_view(url='/static/favicon/favicon.ico')),
Nice solution, thanks!
thanks it works 👍
I move HttpResponseRedirect(settings.STATIC_URL+'ico/favicon.ico')
to separate view function for keep codes clean ;)
it works, thank you~~~
This will work for those using Django 2.x and later...
from django.views.generic.base import RedirectView
path('favicon.ico/', RedirectView.as_view(url='/static/img/favicon/favicon.ico')),
NB:
Please put this in urls.py in your project folder; that is the folder which contains the "settings.py" file.
Also, take note of the location of the favicon.ico path. If your favicon.ico is located in "image" folder, then you have to provide that path like below:
path('favicon.ico/', RedirectView.as_view(url='/static/image/favicon.ico')),
it works, thank you!!!
on django 3.1.5, it works, thanks
or just put this in your urls.py:
url(r'^favicon\.ico$', RedirectView.as_view(url='/static/favicon/favicon.ico')),