[Django] #34864: Add ability to customise script tags for form media

7 views
Skip to first unread message

Django

unread,
Sep 22, 2023, 4:50:37 AM9/22/23
to django-...@googlegroups.com
#34864: Add ability to customise script tags for form media
---------------------------------------+------------------------
Reporter: Tom Carrick | Owner: nobody
Type: New feature | Status: new
Component: Forms | Version: dev
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
---------------------------------------+------------------------
It would be useful to be able to add `defer`, `integrity`,
`type="module"`, etc. onto the script tags generated by form media.

I couldn't find a way to do this currently. Perhaps something like this:

{{{
class MyForm(forms.Form):
class Media:
js = [
{"src": "js/foo.js", "defer": True, "type": "module"},
"js/bar.js",
]
}}}

Not sure if we should allow arbitrary stuff to be added or just choose the
options that are reasonable

--
Ticket URL: <https://code.djangoproject.com/ticket/34864>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Sep 22, 2023, 5:05:18 AM9/22/23
to django-...@googlegroups.com
#34864: Add ability to customise script tags for form media
-----------------------------+--------------------------------------

Reporter: Tom Carrick | Owner: nobody
Type: New feature | Status: closed
Component: Forms | Version: dev
Severity: Normal | Resolution: duplicate

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+--------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed
* resolution: => duplicate


Comment:

I think it's possible since 4c76ffc2d6c77c850b4bef8d9acc197d11c47937 by
using a class instead of paths, check out an
[https://github.com/django/django/blob/4de31ec680df062e5964b630f1b881ead5004e15/tests/forms_tests/tests/test_media.py#L761-L771
example] for `integrity`. Duplicate of #29490.

--
Ticket URL: <https://code.djangoproject.com/ticket/34864#comment:1>

Reply all
Reply to author
Forward
0 new messages