https://github.com/django/django/blob/main/django/forms/widgets.py#L82
It would be great to support type=module right there.
--
Ticket URL: <https://code.djangoproject.com/ticket/33336>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => closed
* resolution: => duplicate
Comment:
As far as I'm aware we can close is as a duplicate of more general ticket
#9357.
--
Ticket URL: <https://code.djangoproject.com/ticket/33336#comment:1>
Comment (by James Pic):
And that's how the decision has been made to not support ESM in Django.
There goes a very convenient feature for modern web development!
--
Ticket URL: <https://code.djangoproject.com/ticket/33336#comment:2>
Comment (by Mariusz Felisiak):
Replying to [comment:2 James Pic]:
> And that's how the decision has been made to not support ESM in Django.
There goes a very convenient feature for modern web development!
I wouldn't say that. There are other media types that we could support
but the first step to opening this door is to handle `Media` subclasses in
Django. It would be straightforward to support JavaScript modules (or
others) with #9357, e.g.:
{{{
class MyMedia(Media):
def __init__(self, media=None, css=None, js=None, js_modules=None):
self.js_modules = js_modules
super().__init__(media, css, js)
def render_js_modules(self):
return format_html(...)
}}}
You can start a discussion on the DevelopersMailingList, where you'll
reach a wider audience and see what other think. We can always reopen this
ticket after reaching a consensus that JavaScript modules should be
treated and handled separately.
--
Ticket URL: <https://code.djangoproject.com/ticket/33336#comment:3>
Comment (by James Pic):
Thank you Mariusz! I'm not on the mailing list but if anyone's looking for
an example they can use there's one here I just made up:
https://yourlabs.io/oss/djhacker/-/commit/9695044ebb6047b86bf3d573383f412a5917bfc9
--
Ticket URL: <https://code.djangoproject.com/ticket/33336#comment:4>