Search code examples
pythondjangodjango-admindjango-staticfiles

Replacing django-admin's bootstrap theme's default logo


I have generated a django-admin for my app and I can access the dashboard. But it contains a logo that says "django admin". I want to change it to my own custom logo. How can I do that?

I have tried adding a base.html file to admin directory and tried to override but for some reason it's not working. It's code is as follows:

{% extends "admin/base.html" %}
{% load theming_tags %}
{% load staticfiles %}
{% block blockbots %}
    {{ block.super }}
    {# Using blockbots ensures theming css comes after any form media and other css #}
    {% render_theming_css %}
    <style type="text/css">
    #header #branding h1 {
        background-image: url("bootstrap_admin/img/logo-140x60.png");
    }
    </style>
{% endblock %}

{% block branding %}
<a href="{% url 'admin:index' %}" class="django-admin-logo">
    <!-- Django Administration -->
    <img src="{% static "bootstrap_admin/img/logo-140x60.png" %}" alt="{{ site_header|default:_('Django Admin') }}">
</a>
{% endblock branding %}

screenshot

I want to change the logo in the top-left corner. How can I achieve what I'm trying to?


Solution

  • your question is answered here

    "{% static "bootstrap_admin/img/logo-140x60.png" %}" this comes from here

    django-admin-bootstrap/bootstrap_admin/static/bootstrap_admi‌​n/img/logo-140x60.pn‌​g

    after replacing you need to run command python manage.py collectstaticthen this will work