Display logo in my django-admin

966 Views Asked by At

I plugged Django-jet into my project and it works fine. I am trying to install a logo on the top left corner of my Django-admin, but it failed. I think the following answer is relevant here: Custom logo in django jet.

(venv) ┌─╼ [~/Projects/Work_Projects/clients.voila6.com/v6]
└────╼ ls ..
dev_requirements.pip  dploy.yml  v6_project  media      requirements.pip
dploy                 v6        manage.py    README.md  scripts
(venv) ┌─╼ [~/Projects/Work_Projects/clients.voila6.com/v6]
└────╼ ls
admin.py  clientspace     core       fixtures     messaging  __pycache__  templates  urls.py
apps.py   configurations  customers  __init__.py  orders     settings.py  tests.py   views.py

So templates/admin/base_site.html is in ~/Projects/Work_Projects/clients.voila6.com/v6, media/my_logo.png is in ~/Projects/Work_Projects/clients.voila6.com and MEDIA_URL is in ~/Projects/Work_Projects/clients.voila6.com/v6_project/conf/settings/common.py

Here is my base_site.html file

{# Template: your_app/templates/admin/base_site.html #}
{% load static i18n %}

{# Setup favicon #}
{% block extrahead %}<link rel="shortcut icon" type="image/png" href="{{MEDIA_URL}}v6_favicon.png"/>{% endblock %}

{# Setup browser tab label #}
{% block title %}{{ title }} |  {% trans "Your title" %}{% endblock %}

{# Setup branding #}
{% block branding %}
    <h1 id="site-name">
        <a href="{% url 'admin:index' %}">
            {# Your logo here #}
            <img style="background-color: white" src="{{MEDIA_URL}}{% trans "v6_logo_eng-300x150" %}.png" alt="voila6" height="50%" width="50%">
            <!--<br><br>-->
            <!--</span> {# trans "Your Branding" #%}-->
        </a>
    </h1>
{% endblock %}

I have not a lot of experience with Django and I think I forgot a step, but I can't say which one of them. How could I display my logo on my Django-admin? Knowing that Django-jet works fine.

Tell me if you need some specific details.

0

There are 0 best solutions below