Search code examples
htmldjangodjango-templatesfavicon

Adding a favicon to template on Django


I want to put a favicon in the base.html in my Django project, but it doesn't seems to work. It doesn't display any errors in the browser console, but I don't get the "GET" message in python manage.py runserverconsole.

<link rel="icon" href="{% static 'assets/img/favicon.ico' %}"/>

Other static files such as JS and CSS are working just fine.

Here is my directory print: 1

And my python shell print: 2


Solution

  • You can check the configuration in settings.py

    STATIC_URL = '/static/'
    STATICFILES_DIRS = [
        os.path.join(BASE_DIR, "static"),
    ]
    

    And in your templates, put this line on the to top:

    {% load staticfiles %}