summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorstefan.ivic <contact@stefanivic.com>2024-06-08 15:44:17 +0200
committerSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2024-06-18 16:49:53 +0200
commitce1ad98565d98b7939367b2bcab755c3555ceb42 (patch)
tree334799428166190114e9b72089661947ee9d99ac /docs
parenta0c44d4e23f8f509757f97f28fbbb1ced3382361 (diff)
Fixed #35505 -- Added extrabody block to admin/base.html.
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/contrib/admin/index.txt26
-rw-r--r--docs/releases/5.2.txt4
2 files changed, 29 insertions, 1 deletions
diff --git a/docs/ref/contrib/admin/index.txt b/docs/ref/contrib/admin/index.txt
index 20f2ce7582..504ab62368 100644
--- a/docs/ref/contrib/admin/index.txt
+++ b/docs/ref/contrib/admin/index.txt
@@ -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
=====================
diff --git a/docs/releases/5.2.txt b/docs/releases/5.2.txt
index fb2a1d0177..0a0cfb0aef 100644
--- a/docs/releases/5.2.txt
+++ b/docs/releases/5.2.txt
@@ -37,7 +37,9 @@ Minor features
:mod:`django.contrib.admin`
~~~~~~~~~~~~~~~~~~~~~~~~~~~
-* ...
+* The ``admin/base.html`` template now has a new block
+ :ref:`extrabody <extrabody>` for adding custom code before the closing
+ ``</body>`` tag.
:mod:`django.contrib.admindocs`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~