mirror of
https://github.com/django/django.git
synced 2025-04-15 21:04:36 +00:00
[1.7.x] Improved get_media_prefix template tag example.
Backport of 9a4a9a8a49ed3e38f3038b8d6fc7c405256271f1 from master
This commit is contained in:
parent
1c0f66f371
commit
5de18e50dc
@ -2608,6 +2608,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…
x
Reference in New Issue
Block a user