diff --git a/django/forms/widgets.py b/django/forms/widgets.py
index 76b31dfa00..9d559cbad1 100644
--- a/django/forms/widgets.py
+++ b/django/forms/widgets.py
@@ -72,11 +72,13 @@ class MediaAsset:
self.attributes = attributes
def __eq__(self, other):
+ # Compare the path only, to ensure performant comparison in Media.merge.
return (self.__class__ is other.__class__ and self.path == other.path) or (
isinstance(other, str) and self._path == other
)
def __hash__(self):
+ # Hash the path only, to ensure performant comparison in Media.merge.
return hash(self._path)
def __str__(self):
diff --git a/docs/topics/forms/media.txt b/docs/topics/forms/media.txt
index c40324cba3..889c240514 100644
--- a/docs/topics/forms/media.txt
+++ b/docs/topics/forms/media.txt
@@ -283,14 +283,27 @@ you to pass custom HTML attributes::
css = {
"all": [CSS("pretty.css", media="all", crossorigin="anonymous")],
}
- js = [JS("animations.js", defer=True)]
+ js = [
+ JS(
+ "https://code.jquery.com/jquery-3.3.1.slim.min.js",
+ **{
+ "integrity"="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
+ "crossorigin"="anonymous",
+ "async": True,
+ },
+ ),
+ ]
If this Media definition were to be rendered, it would become the following HTML:
.. code-block:: html+django
-
+
..note:: The ``media`` attribute on the CSS-object overrides the dictionary key.