문제

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

도움이 되었습니까?

해결책

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 %}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top