Loading docs/ref/templates/builtins.txt +5 −3 Original line number Diff line number Diff line Loading @@ -2533,6 +2533,8 @@ get_media_prefix Similar to the :ttag:`get_static_prefix`, ``get_media_prefix`` populates a template variable with the media prefix :setting:`MEDIA_URL`, e.g.:: <script type="text/javascript" charset="utf-8"> var media_path = '{% get_media_prefix %}'; </script> {% load static %} <body data-media-url="{% get_media_prefix %}"> By storing the value in a data attribute, we ensure it's escaped appropriately if we want to use it in a JavaScript context. Loading
docs/ref/templates/builtins.txt +5 −3 Original line number Diff line number Diff line Loading @@ -2533,6 +2533,8 @@ get_media_prefix Similar to the :ttag:`get_static_prefix`, ``get_media_prefix`` populates a template variable with the media prefix :setting:`MEDIA_URL`, e.g.:: <script type="text/javascript" charset="utf-8"> var media_path = '{% get_media_prefix %}'; </script> {% load static %} <body data-media-url="{% get_media_prefix %}"> By storing the value in a data attribute, we ensure it's escaped appropriately if we want to use it in a JavaScript context.