Friday 13 September 2013

How to use a variable in img tag in Django Templates

How to use a variable in img tag in Django Templates

I have started using Django templates for web programming. I am using
templates, and while giving the img src as a variable, it is not showing
the image. Even when i hard-code the image path, it is still not showing
the image. can somebody help me out here.
Below is my code snippet..
{%extends 'temp1_pr1.html'%}
{%block title%} {{t_name}} Team Sheet{%endblock%}
{%block content%}
<!-- <div
style="color:{{color_v}};width:200px;height:125px;text-align:center" >
<img src =
'D:/Train-files/Django-apps/Project1/Pr1_templates/sachin.jpg'
width = 200 height = 100 >
</div> -->
<p>
<img src =
'D:/Train-files/Django-apps/Project1/Pr1_templates/sachin.jpg'
width = 200 height = 100 >
</p>
{%if list %}
<h2> Below is the team sheet of {{t_name}} </h2>
{%for name in list %}
<h1>{{name}}</h1>
{%endfor%}
{%endif%}
{{some_content}}
{%endblock%}
In image src, i have also used src= {{variable}}, but it is also not
working. I am facing the same problem for background-image as well...

No comments:

Post a Comment