How to change django wagtail's admin logo
Asked Answered
D

2

7

I am working on a small project and I thought I'd give wagtail a try. I am now wondering how I could change wagtail's admin logo in the sidebar (top left image on the picture bellow).

github wagtail image

I could change /static/wagtailadmin/images/wagtail-logo.svg directly but it'd be wrong ;).

Diffidence answered 2/7, 2014 at 16:9 Comment(0)
T
11

Wagtail already provide the solution in the official documentation using django-overextends:

To replace the default logo, create a template file your_app/templates/wagtailadmin/base.html that overrides the block branding_logo as follow:

{% overextends "wagtailadmin/base.html" %}

{% block branding_logo %}
    <img src="{{ STATIC_URL }}images/custom-logo.svg" alt="Custom Project" width="80" />
{% endblock %}

Check Wagtail Custom branding for more details.


(Edit Dec - 2020)

Note: In the latests versions of Wagtail django-overextends is not needed anymore. It uses now the default extends tag of Django templates. Consult the docs for more information

Turnip answered 29/1, 2016 at 13:31 Comment(3)
Cool, this documentation was added on v1.0 and wasn't released at the time of writing question, thanks for sharing this :) This seems like the right answer nowDiffidence
Now, 4 years after this answer was wrote, django-overextends is not needed anymore. See the docsGreeneyed
@YasielCabrera thanks for sharing. Would you please add it as a Note at the beginning of the response, I will approve it.Turnip
C
9

The logo is defined here:

https://github.com/torchbox/wagtail/blob/master/wagtail/wagtailadmin/templates/wagtailadmin/base.html#L7

To override it, you'll need an app which contains templates/wagtailadmin/base.html and precedes wagtail in INSTALLED_APPS.

Good luck!

Clan answered 2/7, 2014 at 18:48 Comment(2)
Thanks!, I didn't know I needed to have my app in front of others to override templates, very useful. I just found that when using TEMPLATE_DIRS = (os.path.join(PROJECT_ROOT, 'templates'),) in settings, templates placed in this directory also overrides other apps so no need to mess with app order :)Diffidence
A more in-depth explanation can be found in the current wagtail documentation (docs.wagtail.io/en/v1.0b1/howto/custom_branding.html). Also, django-overextends is a great way to override 3rd-party templates cleanly.Imperforate

© 2022 - 2024 — McMap. All rights reserved.