We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c5a8b44 commit 7d3418cCopy full SHA for 7d3418c
docs/ref/templates/builtins.txt
@@ -2533,6 +2533,8 @@ get_media_prefix
2533
Similar to the :ttag:`get_static_prefix`, ``get_media_prefix`` populates a
2534
template variable with the media prefix :setting:`MEDIA_URL`, e.g.::
2535
2536
- <script type="text/javascript" charset="utf-8">
2537
- var media_path = '{% get_media_prefix %}';
2538
- </script>
+ {% load static %}
+ <body data-media-url="{% get_media_prefix %}">
+
2539
+By storing the value in a data attribute, we ensure it's escaped appropriately
2540
+if we want to use it in a JavaScript context.
0 commit comments