diff --git a/django/contrib/admin/templates/admin/base.html b/django/contrib/admin/templates/admin/base.html index b9811a0bdb..5d90bea54e 100644 --- a/django/contrib/admin/templates/admin/base.html +++ b/django/contrib/admin/templates/admin/base.html @@ -69,11 +69,15 @@ {% endblock %} - {% block breadcrumbs %} -
+ {% block nav-breadcrumbs %} + {% endblock %} {% endif %} diff --git a/django/contrib/admin/templates/admin/index.html b/django/contrib/admin/templates/admin/index.html index 5674264093..af4f26dec5 100644 --- a/django/contrib/admin/templates/admin/index.html +++ b/django/contrib/admin/templates/admin/index.html @@ -7,7 +7,7 @@ {% block bodyclass %}{{ block.super }} dashboard{% endblock %} -{% block breadcrumbs %}{% endblock %} +{% block nav-breadcrumbs %}{% endblock %} {% block nav-sidebar %}{% endblock %} diff --git a/django/contrib/admin/templates/admin/login.html b/django/contrib/admin/templates/admin/login.html index a14e91c5d7..b61d9ec603 100644 --- a/django/contrib/admin/templates/admin/login.html +++ b/django/contrib/admin/templates/admin/login.html @@ -15,7 +15,7 @@ {% block content_title %}{% endblock %} -{% block breadcrumbs %}{% endblock %} +{% block nav-breadcrumbs %}{% endblock %} {% block content %} {% if form.errors and not form.non_field_errors %} diff --git a/docs/releases/4.2.txt b/docs/releases/4.2.txt index 7ca4f0271e..80c0d97bfc 100644 --- a/docs/releases/4.2.txt +++ b/docs/releases/4.2.txt @@ -48,6 +48,9 @@ Minor features :attr:`~django.contrib.admin.ModelAdmin.filter_vertical` widgets are now filterable. +* The ``admin/base.html`` template now has a new block ``nav-breadcrumbs`` + which contains the navigation landmark and the ``breadcrumbs`` block. + :mod:`django.contrib.admindocs` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/tests/admin_views/test_breadcrumbs.py b/tests/admin_views/test_breadcrumbs.py new file mode 100644 index 0000000000..ee4285f9a9 --- /dev/null +++ b/tests/admin_views/test_breadcrumbs.py @@ -0,0 +1,25 @@ +from django.contrib.auth.models import User +from django.test import TestCase, override_settings +from django.urls import reverse + + +@override_settings(ROOT_URLCONF="admin_views.urls") +class AdminBreadcrumbsTests(TestCase): + @classmethod + def setUpTestData(cls): + cls.superuser = User.objects.create_superuser( + username="super", + password="secret", + email="super@example.com", + ) + + def setUp(self): + self.client.force_login(self.superuser) + + def test_breadcrumbs_absent(self): + response = self.client.get(reverse("admin:index")) + self.assertNotContains(response, '