From e5ac9471c3dc640fab99f69d02fd3c551f336976 Mon Sep 17 00:00:00 2001 From: Marco Acierno Date: Mon, 30 Nov 2026 15:44:42 +0100 Subject: [PATCH] Restore admin object tools after the Django 6.1 upgrade admin/base.html is replaced by the Astro template, which extends pycon_base.html, which extends django_base.html: a vendored copy of Django's admin base.html taken around Django 5.1. Django 6.1 moved the object-tools block out of the content block into a new titles-and-tools wrapper. change_list.html and change_form.html override content and define object-tools as a sibling, so with the stale copy the block was dropped: the changelist "Add" button, the change form "History" button and our custom object-tools items all disappeared. Re-sync django_base.html with Django 6.1.3's admin/base.html (the old copy had no local edits) and add a test that renders a changelist through the real template chain and checks the object tools are there. --- .../templates/admin/django_base.html | 49 +++++++++++-------- .../tests/test_template_backends.py | 17 +++++++ 2 files changed, 45 insertions(+), 21 deletions(-) diff --git a/backend/custom_admin/templates/admin/django_base.html b/backend/custom_admin/templates/admin/django_base.html index f01a7ab61c..b8330c02f5 100644 --- a/backend/custom_admin/templates/admin/django_base.html +++ b/backend/custom_admin/templates/admin/django_base.html @@ -1,30 +1,32 @@ -{% load i18n static %} +{% load i18n static tz %} {% get_current_language as LANGUAGE_CODE %}{% get_current_language_bidi as LANGUAGE_BIDI %} {% block title %}{% endblock %} - + + {% block dark-mode-vars %} - - + + {% endblock %} {% if not is_popup and is_nav_sidebar_enabled %} - - + + {% endif %} {% block extrastyle %}{% endblock %} -{% if LANGUAGE_BIDI %}{% endif %} +{% if LANGUAGE_BIDI %}{% endif %} {% block extrahead %}{% endblock %} {% block responsive %} - - {% if LANGUAGE_BIDI %}{% endif %} + + {% if LANGUAGE_BIDI %}{% endif %} {% endblock %} {% block blockbots %}{% endblock %} + data-admin-utc-offset="{% now "Z" %}" + data-admin-server-timezone="{% get_current_timezone as time_zone %}{{ time_zone }}"> {% translate 'Skip to main content' %}
@@ -72,10 +74,10 @@ {% block nav-breadcrumbs %} {% endblock %} @@ -97,11 +99,15 @@ {% endblock messages %}
- {% block pretitle %}{% endblock %} - {% block content_title %}{% if title %}

{{ title }}

{% endif %}{% endblock %} - {% block content_subtitle %}{% if subtitle %}

{{ subtitle }}

{% endif %}{% endblock %} - {% block content %} +
+
+ {% block pretitle %}{% endblock %} + {% block content_title %}{% if title %}

{{ title }}

{% endif %}{% endblock %} + {% block content_subtitle %}{% if subtitle %}

{{ subtitle }}

{% endif %}{% endblock %} +
{% block object-tools %}{% endblock %} +
+ {% block content %} {{ content }} {% endblock %} {% block sidebar %}{% endblock %} @@ -116,10 +122,11 @@ - - - + + + +{% block extrabody %}{% endblock extrabody %} diff --git a/backend/custom_admin/tests/test_template_backends.py b/backend/custom_admin/tests/test_template_backends.py index d693e153e1..bed4233e5c 100644 --- a/backend/custom_admin/tests/test_template_backends.py +++ b/backend/custom_admin/tests/test_template_backends.py @@ -1,5 +1,6 @@ import pytest from unittest.mock import Mock, mock_open, patch +from django.urls import reverse from custom_admin.template_backends import ( AstroContentLoader, CustomAdminDjangoTemplate, @@ -76,3 +77,19 @@ def test_astro_content_loader_ignores_non_admin_base_templates(settings, templat loader = AstroContentLoader(engine=Mock()) with pytest.raises(StopIteration): next(loader.get_template_sources(template_name)) + + +def test_admin_changelist_shows_object_tools( + client, admin_superuser, requests_mock, settings +): + settings.DEBUG = True + requests_mock.get( + "http://127.0.0.1:8000/astro/admin-base.html", + text="{% extends 'admin/pycon_base.html' %}", + ) + client.force_login(admin_superuser) + + response = client.get(reverse("admin:conferences_topic_changelist")) + + assert response.status_code == 200 + assert '
    ' in response.content.decode()