You can show favicon on your browser with Django Development server. *My answer explains how to set favicon in Django Admin.
For example, there is favicon.ico
in static/
and there is base.html
in templates/
as shown below:
django-project
|-core
| └-settings.py
|-my_app1
|-my_app2
|-static
| └-favicon.ico # Here
└-templates
└-base.html # Here
Then, set BASE_DIR / 'templates'
to DIRS in TEMPLATES and set BASE_DIR / 'static/'
in STATICFILES_DIRS in settings.py
as shown below so that Django can recognize templates
and static
folders just under django-project
. *My answer explains how to set Django Templates and I recommand to set whitenoise following my answer to disable your browser to cache the static files of Django:
# "settings.py"
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
BASE_DIR / 'templates' # Here
],
...
},
]
...
STATIC_URL = 'static/'
STATICFILES_DIRS = [
BASE_DIR / 'static/' # Here
]
Lastly, add <link rel="icon" ...>
to <head></head>
in base.html
as shown below:
{# "base.html" #}
<head>
...
<link rel="icon" href="{% static 'favicon.ico' %}"/> {# Here #}
...
</head>
In addition, if favicon is not shown on your browser, use different urls as shown below. *My answer explains it:
http://localhost:8000/...
http://localhost:8001/...
http://localhost:8002/...
http://localhost: :: /...
http://127.0.0.1:8000/...
http://127.0.0.1:8001/...
http://127.0.0.1:8002/...
http://127.0.0.1: :: /...
GET /favicon.ico
notGET /static/favicon.ico
looking inhttp://localhost:8000/static/favicon.ico
is not related. It looks like some browsers requests for/favicon.ico
despites the HTML.