Question

I try to achieve the following:

<img src="/static/teammembers/some_name">

but if I write <img src="{% static 'teammembers/{{ image }} %}"> in the template,
then the rendered output is

<img src="/static/teammembers/{{ image }}">

what am I doing wrong?

EDIT:

In my case the solution for this question does not work, since I use an automatic cachebuster (django-cachebuster).

Was it helpful?

Solution

You can use with with an add template filter as suggested here:

{% with 'teammembers/'|add:image as image_static %}
    <img src="{% static image_static %}">
{% endwith %}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top