0

cant override the django admin site page, i just want to put a logo in my admin page, did i miss something in my code?

I already run, python manage.py collectstatic and ofcourse that logo image is exist in my static folder

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'templates/')],
        'APP_DIRS': True,


LOGIN_REDIRECT_URL = '/'
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')


import os

MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')

enter image description here

template

{% extends "admin/base.html" %}

{% load staticfiles %}

{% block title %}{{ title }} | {{ site_title|default:_('Django site admin') }}{% endblock %}

{% block branding %}
<h1 id="site-name">
    <a href="{% url 'admin:index' %}">
        <img src="{% static 'logo.png' %}" height="40px" />
    </a>
</h1>
{% endblock %}

{% block nav-global %}{% endblock %}

1 Answers1

0

Your question is here

If your STATICFILES_DIRS is empty set it to:

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

See more explation.

mhhabib
  • 2,975
  • 1
  • 15
  • 29
  • `django.core.exceptions.ImproperlyConfigured: You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path.` –  Nov 24 '20 at 05:16
  • Don't you have a static file? – mhhabib Nov 24 '20 at 05:21
  • Give a try by setting image path like `{% static 'img/logo.png' %}` and before that add a new folder name `img` in static and paste the logo in `img` folder – mhhabib Nov 24 '20 at 05:58