DCR
DCR

Reputation: 15647

django favicon icon does not display

I have the following django project file structure:

lecture3/
    lecture3/
        urls.py
    tasks/
        static/
            img/
                favicon.ico
        urls.py

my tasks/urls.py file is:

from django.urls import path
from . import views

from django.contrib.staticfiles.storage import staticfiles_storage
from django.views.generic.base import RedirectView

app_name = 'tasks'

urlpatterns = [
    path("",views.index, name="index" ),
    path("add",views.add, name="add" ),      
    path('favicon.ico', RedirectView.as_view(url=staticfiles_storage.url('img/favicon.ico'))),
]

but when I run I get a 404 error. How do I fix this?

Upvotes: 1

Views: 243

Answers (1)

Chris W
Chris W

Reputation: 11

Try looking in your settings.py file for STATIC_URL = '/static/'. I moved my favicon.ico into this directory and my problem went away. I don't have it in my urlpatterns.

Upvotes: 1

Related Questions