1

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

Community
  • 1
  • 1
Barney Szabolcs
  • 11,846
  • 12
  • 66
  • 91

1 Answers1

2

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 %}
Community
  • 1
  • 1
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195