How can I call external javascript in my default admin html page in Django.
I know that using MEDIA class I can do this in admin.py file.
Here is the my try:
class PlayerAdmin(admin.ModelAdmin):
class Media:
js = ('/static_files/js/adminsettings.js')
But I am not getting data written in the JavaScript file.
You need to use a path relative to
STATIC_URL(orMEDIA_URL), in your example this may work:Also, not that the
jsattribute 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.