1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #35505 -- Added extrabody block to admin/base.html.

This commit is contained in:
stefan.ivic
2024-06-08 15:44:17 +02:00
committed by Sarah Boyce
parent a0c44d4e23
commit ce1ad98565
5 changed files with 36 additions and 1 deletions

View File

@@ -2827,6 +2827,32 @@ linked to the document in ``{% block dark-mode-vars %}``.
.. _prefers-color-scheme: https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme
.. _extrabody:
``extrabody`` block
===================
.. versionadded:: 5.2
You can add custom HTML, JavaScript, or other content to appear just before the
closing ``</body>`` tag of templates that extend ``admin/base.html`` by
extending the ``extrabody`` block. For example, if you want an alert to appear
on page load you could add a ``admin/base.html`` template override to your
project:
.. code-block:: html+django
{% extends 'admin/base.html' %}
{% block extrabody %}
{{ block.super }}
<script>
document.addEventListener('DOMContentLoaded', function() {
window.alert('Welcome!');
});
</script>
{% endblock extrabody %}
``AdminSite`` objects
=====================