set favicon in django admin

前端 未结 4 1692
醉酒成梦
醉酒成梦 2021-02-18 14:08

I need to set up a favicon for django admin interface.

It would be best to do it globally, without overriding templates for all apps.

What is the cleanest way

4条回答
  •  别那么骄傲
    2021-02-18 14:24

    If favicon is in '/app/static/img/favicon.ico', link it into the {% block extrahead %} of this file: '/app/templates/admin/base_site.html'

        {% extends "admin/base.html" %}
    
        {% block title %}{{ title }} | {{ site_title|default:_('Django site admin') }}{% endblock %}
    
        {% block extrahead %}
            
        {% endblock %}
        {% block branding %}
            

    {{ site_header|default:_('Django administration') }}

    {% endblock %}

    In settings.py INSTALLED_APPS be sure your app is listed before django.contrib.admin.

    To test get rid of template cache by deleting .pyc files: "$find . -name \"*.pyc\" -delete".

    Works with Django 1.8.12 Firefox, Chrome.

提交回复
热议问题