Skip to content

Commit

Permalink
Fixed #34905 -- Corrected admin's main content element rendered in <m…
Browse files Browse the repository at this point in the history
…ain> tag.

Regression in 91e617c.

Thanks Tom Carrick for the report.
  • Loading branch information
ontowhee authored Oct 19, 2023
1 parent 71a813a commit 89d2ae2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
8 changes: 4 additions & 4 deletions django/contrib/admin/templates/admin/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@
{% endblock %}
{% endif %}

<main class="main" id="main">
<div class="main" id="main">
{% if not is_popup and is_nav_sidebar_enabled %}
{% block nav-sidebar %}
{% include "admin/nav_sidebar.html" %}
{% endblock %}
{% endif %}
<div id="content-start" class="content" tabindex="-1">
<main id="content-start" class="content" tabindex="-1">
{% block messages %}
{% if messages %}
<ul class="messagelist">{% for message in messages %}
Expand All @@ -109,8 +109,8 @@
</div>
<!-- END Content -->
{% block footer %}<div id="footer"></div>{% endblock %}
</div>
</main>
</main>
</div>
</div>
<!-- END Container -->

Expand Down
2 changes: 1 addition & 1 deletion tests/admin_views/test_nav_sidebar.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def setUp(self):

def test_sidebar_not_on_index(self):
response = self.client.get(reverse("test_with_sidebar:index"))
self.assertContains(response, '<main class="main" id="main">')
self.assertContains(response, '<div class="main" id="main">')
self.assertNotContains(
response, '<nav class="sticky" id="nav-sidebar" aria-label="Sidebar">'
)
Expand Down
7 changes: 7 additions & 0 deletions tests/admin_views/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1598,6 +1598,13 @@ def test_header(self):
response = self.client.get(reverse("admin:login"))
self.assertContains(response, '<header id="header">')

def test_main_content(self):
response = self.client.get(reverse("admin:index"))
self.assertContains(
response,
'<main id="content-start" class="content" tabindex="-1">',
)


@override_settings(
AUTH_PASSWORD_VALIDATORS=[
Expand Down

0 comments on commit 89d2ae2

Please sign in to comment.