Js files in the admin

I load some js files in the admin using a custom admin site, let's call it custom_admin_site.html. In this template I override some blocks:

{% extends "admin/base_site.html" %}
{% load i18n static %}


{% block extrahead %}
    <link rel="shortcut icon" href="{% static 'images/favicon.ico' %}" />
    <script src="{% static 'admin/src-min-noconflict/ace.js' %}" referrerpolicy="no-referrer"></script>
    <script src="{% static 'js/htmx.min-1.9.11.js' %}"></script>
{% endblock %}

When I use these libraries, on the main page (/admin) they work just fine.

When I override other templates, for example I have: projectname \ templates \ admin \ appname \ modelname \ change_form.html:

{% extends "admin/change_form.html" %}
{% load i18n admin_urls %}
...

and I cannot access my libraries form here.

  1. Do I need to add something like this in my 'change_form.html`?

{% block extrahead %} {{ block.super }} {% endblock %}

  1. or can I somehow make sure that other htmls also use my extended custom_admin_site.html and not the normal admin/base_site.html?
  2. Or am I approaching this the wrong way and should I define a Media subclass with the js files in the admin.py where it is needed?
Back to Top