How to add script type="module" in django admin
03:05 21 May 2019

If I want some javascript functionality in my Django admin, I usually go about it using the Media class like this:

@admin.register(MyModel)
class MyModelAdmin(admin.ModelAdmin):

    class Media:
        js = ('js/my_script.js',)

But I now have a script that is a ES6 module so I would like Django to render it like:


and using the Media class doesn't render the type="module" attribute.

Any help or tips to achieve this? Thanks

python django es6-modules