Python Forum

Full Version: SHow image in a static link of Django
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

How can i show the image t ?

{% for t in liste_theme_key %}[/color]
                <div>
                  
                  <a href="/verset/" ><img class="image_theme" src="{% static 'accueil/img/{{ t }}.png' %}"/></a>
                  
                </div>
{% endfor %}
It fine to show images that are not code, what is objected to is images of code.
I hope something like the following helps you:
{% for t in liste_theme_key %}
<div>
{% with 'accueil/img/'|add:t|add:'.png' as png_url %}
<a href="/verset/" ><img class="image_theme" src="{% static png_url %}"/></a>
{% endwith %}                   
</div>
{% endfor %}
(Mar-03-2020, 01:33 PM)scidam Wrote: [ -> ]I hope something like the following helps you:
{% for t in liste_theme_key %}
<div>
{% with 'accueil/img/'|add:t|add:'.png' as png_url %}
<a href="/verset/" ><img class="image_theme" src="{% static png_url %}"/></a>
{% endwith %}                   
</div>
{% endfor %}

Hi,
It works fine. Thank you so much. .