How to load a custom JS file in Django admin home?

前端 未结 1 367
情歌与酒
情歌与酒 2020-12-01 18:18

I have a heavily customized Django admin where it\'s very simple to load a custom JS file for each of my ModelAdmins:

class MyModelAdmin(admin.ModelAdmin):
          


        
相关标签:
1条回答
  • 2020-12-01 18:43

    You can override templates/admin/index.html and add the JavaScript in the block extrahead:

    {% extends "admin/index.html" %}
    
    {% block extrahead %}
        {{ block.super }}
        # add a <script> tag here with your JavaScript
    {% endblock %}
    
    0 讨论(0)
提交回复
热议问题