Friday, July 19, 2019

trying to use a variable inside a static content tag

Greetings.  I am writing a card game and I can load an image when I give a fixed value such as:

<img src="{% static "app/images/ah.png" alt="ah" style="width:69px;height:106px;">

but I would actually like part o fthis to be determined by a tag (there is a for loop setting values) but when I write:

<img src="{% static "app/images/{{ card }}.png" %}"" alt="{{ card }}" style="width:69px;height:106px;">

however when this is rendered into HTML the tag {{ card }} ha sbeen URL-escaped:

<img src"=/static/%7B%7B%20card%20%7D%7D"" alt="KC.png" style="width:69px;height:106px;">

How can I render a static image based on the contents of a tag?


Cheers,

Lyman Hurd


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/03cc0571-43ea-40ef-bced-bbfdeb8a43df%40googlegroups.com.

No comments:

Post a Comment