How to remove breadcrumbs in Django admin

488 views
Skip to first unread message

Marwan Al-Sabbagh

unread,
Mar 17, 2014, 1:32:43 AM3/17/14
to django...@googlegroups.com
For reference I've asked this question on stackoverflow: http://stackoverflow.com/q/22345527/1699750

How can I use nav-global for navigation and hide the breadcrumbs in the django admin app. I've found ways to do this but they seem hackish and problematic. I'm looking for a clean reliable solution.

**Naive Approach that doesn't work:**

customize admin/base_site.html

    {% extends "admin/base.html" %}
    {% load i18n %}
   
    {% block title %}{{ title }} | {% trans 'Django site admin' %}{% endblock %}
   
    {% block branding %}
    <h1 id="site-name">{% trans 'Django administration' %}</h1>
    {% endblock %}
   
    {% block nav-global %}Some links will go here...{% endblock %}
    {% block breadcrumbs %}{% endblock %}

this doesn't work because the templates in django admin like change_list.html that extend base_site.html will define content for breadcrumbs which will override whatever I have set in base_site.html.

**solution 1: CSS**

Add the following css to admin using the extrastyle block. This works, but the breadcrumbs still get generated and appear in the HTML source. This feels hacky.

    .breadcrumbs {
        display: none;
    }

**Solution 2: override base.html**

Override base.html and remove the breadcrumbs block. Children will try to define it but it never exists so it never gets rendered. This also seems like a hack. It's also not a good idea to override base.html as each Django release can make many changes to base.html and the admin app could break between releases.

I just wanted to make sure there isn't some simpler way that I'm missing. Thanks in advance.

Cheers,
Marwan AlSabbagh


Reply all
Reply to author
Forward
0 new messages