[Answer]-Call external javascript in the default administration page in Django

1👍

You need to use a path relative to STATIC_URL (or MEDIA_URL), in your example this may work:

  class PlayerAdmin(admin.ModelAdmin):
      class Media:
        js = ('js/adminsettings.js',)

Also, not that the js attribute is a tuple in my example (it can be any iterable, a list, set, etc.)

An alternative is overriding admin templates, which can give you more flexibility, and allow you to apply the same javascript to many models easily.

Leave a comment