Why setting src of img by jquery in Django does not have to include {{MEDIA_URL}} -
just curious question. in order display image image in {{media_url}}, need in django:
<img src="{{media_url}} + file-url ">
with jquery, don't have include {{media_url}}:
$('.myimg').attr('src',"file-url");
why?
because django don't parse .js files. include media_url in js files should in base template in head section:
<script type="text/javascript"> var mediaurl = '{{ media_url }}'; </script>
then can use in scripts:
$('.myimg').attr('src', mediaurl + file-url);
Comments
Post a Comment