django-jet icon indicating copy to clipboard operation
django-jet copied to clipboard

Replacing my logo (image) with 'Django Administration'

Open ghost opened this issue 8 years ago • 16 comments

Hi,

What is the best practice for replacing my company's logo file with the 'Django Administration' title?

Thx!

ghost avatar Dec 20 '16 15:12 ghost

In the upper right corner?

SalahAdDin avatar Dec 21 '16 18:12 SalahAdDin

There are site_header and site_title attributes of Site so I set an ADMIN_SITE_HEADER in settings, and this in the urls.py file:

if hasattr(settings, 'ADMIN_SITE_HEADER'):
    admin.site.site_header = settings.ADMIN_SITE_HEADER
    admin.site.site_title = settings.ADMIN_SITE_HEADER

This will change both, the visible title in the right top corner and the one in <title> of the site's HTML.

rcotrina94 avatar Jan 14 '17 17:01 rcotrina94

@rcotrina94 could you please give me an example of what to put in ADMIN_SITE_HEADER?

I have ADMIN_SITE_HEADER = '<img src="logo_bg.png" alt="BE Group logo">' but I can't see the logo, just the normal title.

Edit: site_header and site_title are both of type django.utils.functional.lazy.<locals>.__proxy__. I'm not sure how to put there the logo.

Ismael-VC avatar Feb 25 '17 07:02 Ismael-VC

@rcotrina94, your solution doesn't work for logo, i think.

SalahAdDin avatar Feb 25 '17 10:02 SalahAdDin

@cownaf the correct way is documented here:

  • https://github.com/geex-arts/django-jet-demo/blob/1a71b6f6ff327f39a0873902988979eb7163cc3f/templates/admin/base_site.html#L6-L10

You can create a your_app/templates/admin/base_site.html template, something like:

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

{# Setup favicon #}
{% block extrahead %}<link rel="shortcut icon" type="image/png" href="{{MEDIA_URL}}your_logo.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}}your_logo.png" alt="Your Company Name" height="50%" width="50%">
            <br><br>
            </span> {% trans "Your Branding" %}
        </a>
    </h1>
{% endblock %}

It is in the branding block where you can add your logo with an <img ...> tag:

image

Should I make a PR to add this instructions to the documentation?

Ismael-VC avatar Feb 27 '17 10:02 Ismael-VC

@Ismael-VC, yes please! With images also.

SalahAdDin avatar Feb 27 '17 11:02 SalahAdDin

I've found a problem recently, same code as above, but now the logo is out of place, I'm using the latest dev branch:

image

Ismael-VC avatar Apr 08 '17 18:04 Ismael-VC

I think in the dev branch developers didn't take in account all possible uses for these block of code, in concecuence they create global styles for this menu icon only, and not for all block.

Can you try to review this? I want review also my issue.

SalahAdDin avatar Apr 09 '17 11:04 SalahAdDin

@SalahAdDin yes I feel the same similarly with the footer that said Powered by Django-JET. Since this block was not inside an extra block tag, in order to change it, one would have to change the template itself, instead of inheriting from it.

Now this footer has been deleted in dev, but it would be nice to bring it back and make it editable, so the users can decide what to do with this extra branding blocks be it edit it, remove it or leave as is.

The weird thing is that the logo and the code I used was still working correctly, even after the update of the pin for the side menu was introduced, but after the last pip install -r git+git://github.com/geex-arts/django-jet@dev --upgrade the image gets moved downwards and I can't figure out why.

Ismael-VC avatar Apr 09 '17 19:04 Ismael-VC

@Ismael-VC Did you review the code inspecting it in the browser?

SalahAdDin avatar Apr 10 '17 10:04 SalahAdDin

Yes I did, I have reverted back to django-jet master for now, I want to test more things, but when I tested dev, and got this error, If I inspected it, it would tell me that the logo place is right between the two icons, even when you use the mouse selector, but the logo is moved downward non the less, I'll take a screenshot later today.

Ismael-VC avatar Apr 10 '17 13:04 Ismael-VC

@Ismael-VC I tested the new release version, effectively, the problem exist yet: seleccion_328

SalahAdDin avatar Apr 30 '17 12:04 SalahAdDin

I partially solved with this: seleccion_330

Implemented here.

SalahAdDin avatar Apr 30 '17 15:04 SalahAdDin

Please come to the django-jet Discord server so we can organize if you like:

  • https://discord.gg/3yr5yeH

Welcome! 😄

Ismael-VC avatar Aug 15 '17 15:08 Ismael-VC

@SalahAdDin If I want to customize This template by inheriting in my app how can I do it?

I guess this template shows models of an app in a list, the page we see after clicking on an app from the menu. I want to group some models for my application. May be different list for different group like that.

mnislam01 avatar May 06 '19 09:05 mnislam01

@SalchiPapa well, I tried, but after that default Dashboard died, it just dissappeared.

sagata1999 avatar Jan 28 '20 09:01 sagata1999