I found this solution for serving favicon.ico with django.
(r'^favicon\.ico$', 'django.views.generic.simple.redirect_to', {'url': settings.MEDIA_URL+'images/favicon.ico'}),
I do not understand why it only works for the development server. Going to /favicon.ico works on dev, doesn't with debug=False
. It should redirect to /media/images/favicon.ico (served by apache), which does work if you access it directly.
Any ideas?
If you are still getting favicon errors and the Django favicon is not working, you need to make sure the favicon file is spelled correctly and saved in the right folder. The example above uses the path static > img, meaning the favicon is located in the project folder > static > img folder.
Move this file into your project within the static directory so it should be static/favicon. ico . For the final step, update our template so that we include load static at the top and then add an href for our favicon.
I'd recommend against serving the favicon with django unless you absolutely have to. Instead, putting a setting in your web server config that adds an alias pointing to the favicon.
For example, in apache:
Alias /favicon.ico /path/to/media_url/images/favicon.ico
This is not direct answer to you question, but you can use this for favicon:
<link rel="shortcut icon" href="{{ STATIC_URL }}img/favicon.ico" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With