Python Forum
SHow image in a static link of Django
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SHow image in a static link of Django
#1
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 %}
Reply
#2
It fine to show images that are not code, what is objected to is images of code.
Reply
#3
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 %}
Reply
#4
(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. .
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question [Solved] Private static files SpongeB0B 1 1,057 Jul-16-2022, 05:36 AM
Last Post: SpongeB0B
  Flask, Display a picture outisde the static SpongeB0B 6 15,479 Aug-29-2020, 05:15 PM
Last Post: nilamo
  Django: How to automatically substitute a variable in the admin page at Django 1.11? m0ntecr1st0 3 3,309 Jun-30-2019, 12:21 AM
Last Post: scidam
  get link and link text from table metulburr 5 6,280 Jun-13-2019, 07:50 PM
Last Post: snippsat
  How to save uploaded image url in database from Django? PrateekG 14 14,869 Jul-04-2018, 05:18 PM
Last Post: PrateekG
  Show image in qtablewidget lugdanum 0 4,224 Apr-27-2018, 11:30 AM
Last Post: lugdanum
  Django-cms link to a page Alkatron 4 8,247 Apr-06-2018, 10:58 AM
Last Post: Alkatron
  Django loading static files Dutchpy 7 23,943 Oct-13-2017, 10:25 AM
Last Post: hbknjr

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020