Python Forum
SHow image in a static link of Django - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html)
+--- Thread: SHow image in a static link of Django (/thread-24755.html)



SHow image in a static link of Django - pycada - Mar-03-2020

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 %}



RE: SHow image in a static link of Django - Larz60+ - Mar-03-2020

It fine to show images that are not code, what is objected to is images of code.


RE: SHow image in a static link of Django - scidam - Mar-03-2020

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 %}



RE: SHow image in a static link of Django - pycada - Mar-04-2020

(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. .